.htaccess不能在localhost上工作,但在实时服务器上工作(htaccess覆盖打开)

时间:2017-04-03 19:13:06

标签: php apache .htaccess mod-rewrite url-rewriting

这个确切的.htaccess适用于实时服务器,但不适用于localhost(显示带有Web结构的页面),为什么?

RewriteEngine On
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ /public/index.php [L]

这个.htaccess适用于:

RewriteEngine On
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ index.php [L]

我做错了什么,但不知道是什么,请帮助我。

1 个答案:

答案 0 :(得分:0)

/public上是否有localhost个文件夹?看起来这个文件夹只存在于live-system上。或者最终DocumentRoot不同。

无论如何,我看到的唯一区别是:

/public/index.php

这是DocumentRoot的绝对路径。 - > /path/to/DocumentRoot/public/index.php

index.php

应该是DocumentRoot的相对路径。 - > /path/to/DocumentRoot/index.php

确保您正在重写到正确的位置。