繁体   English   中英

.htaccess在localhost上不起作用,但是在实时服务器上起作用(htaccess覆盖处于启用状态)

[英].htaccess doesn't work on localhost, but on live server does (htaccess override is on)

这个确切的.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]

我做错了,但是不知道怎么办,请帮帮我。

localhost上是否有一个/public文件夹? 似乎此文件夹仅存在于实时系统中。 或最终,DocumentRoot有所不同。

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

/public/index.php

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

index.php

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM