Mod_rewrite and Relative URLs

I set some simple URL rewriting rules using mod_rewrite and the .htacces file, but I have some problems. If I configured .htacces this way:

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteRule /index.html /index.php [L]

when I call this URL from the browser: http: //localhost/~dave/mySite/index.html I got a 404 error.

Using this .htacces instead

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteRule /index.html http://localhost/~dave/mySite/index.php [L]

everything works fine and i get the index.php page i expect. Do I force users of absolute URLs to rewrite? Is this an Apache configuration problem?

I am using Max OS X 10.6.2 with a standard Apache installation.

+3
source share
2 answers
  • RewriteBase ; .

  • ; .

  • URL- , , ; .

, :

RewriteRule ^index\.html$ index.php [L]
+4

RewriteRule ^(.*)/index.html $1/index.php [L]

.

0

Source: https://habr.com/ru/post/1735910/


All Articles