简体   繁体   中英

.htaccess file not working on localhost XAMPP

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

<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:

# 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?

You can use this rule in root .htaccess:

RewriteEngine On
RewriteBase /

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

using XAMPP then you will find the file at:

{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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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