.htaccess文件无法在localhost XAMPP上运行

时间:2022-02-13 10:51:26

I have PHP project on localhost using XAMPP and also .htaccess file:

我使用XAMPP和.htaccess文件在localhost上有PHP项目:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /locations/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test.php [L]
</IfModule>

But this is not working and I am only getting Error 404. In httpd.conf file I have uncommented this line:

但这不起作用,我只得到错误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

I am using Windows 8.1. What can I do to make it work, please?

我使用的是Windows 8.1。我能做些什么才能让它发挥作用呢?

2 个解决方案

#1


6  

You can use this rule in root .htaccess:

您可以在root .htaccess中使用此规则:

RewriteEngine On
RewriteBase /

RewriteRule ^locations(/.*)?$ test.php [L,NC]

#2


2  

using XAMPP then you will find the file at:

使用XAMPP,您将在以下位置找到该文件:

{xampp_dir}/apache/conf/httpd.conf

{} xampp_dir /apache/conf/httpd.conf

Search for the following string:

搜索以下字符串:

LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it (remove the ‘#’ sign). Now search for another string AllowOverride None and replace it by AllowOverride All

并取消注释(删除'#'符号)。现在搜索另一个字符串AllowOverride None并将其替换为AllowOverride All

#1


6  

You can use this rule in root .htaccess:

您可以在root .htaccess中使用此规则:

RewriteEngine On
RewriteBase /

RewriteRule ^locations(/.*)?$ test.php [L,NC]

#2


2  

using XAMPP then you will find the file at:

使用XAMPP,您将在以下位置找到该文件:

{xampp_dir}/apache/conf/httpd.conf

{} xampp_dir /apache/conf/httpd.conf

Search for the following string:

搜索以下字符串:

LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it (remove the ‘#’ sign). Now search for another string AllowOverride None and replace it by AllowOverride All

并取消注释(删除'#'符号)。现在搜索另一个字符串AllowOverride None并将其替换为AllowOverride All