【发布时间】:2015-02-23 19:20:39
【问题描述】:
我在 localhost 上使用 XAMPP 和 .htaccess 文件有 PHP 项目:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /locations/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test.php [L]
</IfModule>
但这不起作用,我只收到错误 404。在 httpd.conf 文件中,我取消了对这一行的注释:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
我使用的是 Windows 8.1。请问我该怎么做才能让它工作?
【问题讨论】:
-
C:\xampp\htdocs\myProjectRoot
-
因为我想重定向 url - 当我请求 localhost/myProjectRoot/locations/ 时,我想重定向到 localhost/myProjectRoot/test.php。我猜它在生产服务器版本上运行良好,但由于这个 .htaccess 问题而不在 localhost 上运行。
-
但是我没有位置文件夹,我想要这个:当用户键入 localhost/myProjectRoot/locations/ 时,它会将他“重定向”到 localhost/myProjectRoot/test.php。所以它会请求这个 php 文件。但我也尝试创建文件夹位置并将此 .htaccess 放在那里,但它不起作用。