.htaccess not working on localhost with XAMPP
Solution 1
Just had a similar issue
Resolved it by checking in 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 <--- make sure this is not set to "None"
It is worth bearing in mind I tried (from Mark's answer) the "put garbage in the .htaccess" which did give a server error - but even though it was being read, it wasn't being acted on due to no overrides allowed.
Solution 2
In conf/extra/httpd-vhosts.conf, add the line AllowOverride All
for all the websites that you are having problem with
<VirtualHost example.site:80>
# rest of the stuff
<Directory "c:\Projects\example.site">
Require all granted
AllowOverride All <-----This line is required
</Directory>
</VirtualHost>
Solution 3
Try
<IfModule mod_rewrite.so>
...
...
...
</IfModule>
instead of <IfModule mod_rewrite.c>
Solution 4
Without seeing your system it's hard to tell what's wrong but try the following (comment answer if these didn't work WITH log error messages)
[STOP your Apache server instance. Ensure it's not running!]
1) move apache server/install to a folder that has no long file names and spaces
2) check httpd.conf in install\conf folder and look for AccessFileName
. If it's .htaccess change it to a file name windows accepts (e.g. conf.htaccess)
3) double-check that your htaccess file gets read: add some uninterpretable garbage to it and start server: you should get an Error 500. If you don't, file is not getting read, re-visit httpd.conf file (if that looks OK, check if this is the only file which defines htaccess and it's location and it does at one place -within the file- only; also check if both httpd.conf and htaccess files are accessible: not encrypted, file access rights are not limited, drive/path available -and no long folder path and file names-)
STOP Apache again, then go on:
4) If you have IIS too on your system, stop it (uninstall it too if you can) from services.msc
5) Add the following to the top of your valid htaccess file:
RewriteEngine On
RewriteLog "/path/logs/rewrite.log" #make sure path is there!
RewriteLogLevel 9
6) Empty your [apache]\logs folder (if you use another folder, then that one :)
7) Check the following entries are set and correct:
Action application/x-httpd-php "c:/your-php5-path/php-cgi.exe"
LoadModule php5_module "c:/your-php5-path/php5apache2.dll"
LoadModule rewrite_module modules/mod_rewrite.so
Avoid long path names and spaces in folder names for phpX install too!
8) START apache server
You can do all the steps above or go one-by-one, your call. But at the end of the day make sure you tried everything above!
If system still blows up and you can't fix it, copy&paste error message(s) from log folder for further assistance
Solution 5
I had a similar problem. But the problem was in the file name '.htaccess', because the Windows doesn't let the file's name begin with a ".", the solution was rename the file with a CMD command. "rename c:\xampp\htdocs\htaccess.txt .htaccess"
Related videos on Youtube
acre
Updated on July 22, 2022Comments
-
acre almost 2 years
i m using XAMPP but i m not able to use .htaccess file at local host. i m trying so many times.. Online working good. but local host showing [The requested URL was not found on this server]
My root folder is real
localhost/acre/real/property_available.php localhost/acre/real/properties <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /acre/real/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^properties$ /property_available.php/$1 [NC,QSA] </IfModule>
Please
-
Admin about 11 yearsIs localhost a windows or another system? Using a virtual host on server or dedicated machine? Is httpd.conf OK on localhost too (ie all other cfg)? Any error log data recorded on localhost? Double-checked that path info is OK (/prop....php)?
-
anubhava about 11 yearsHave you enabled mod_rewrite and .htaccess? What is your DocumentRoot?
-
acre about 11 yearsreal folder is my document root. yaa enabled mod_rewrite and remove #from con file
-
-
RGriffiths almost 9 yearsI am having this issue too but can't find am http.conf file anywhere. Should I definitely have one?
-
TimP over 8 yearsI think you should as its created during a default install. Note it is httpd.conf
-
RGriffiths over 8 yearsThanks - found it. Accessed through the Xampp control panel. I was looking c:/ ..... path etc.
-
mr_plum over 8 yearsThis solved my .htaccess problem in a virtual host. I didn't see this solution mentioned anywhere else. Thank you!
-
Precastic over 7 yearsYou can also always create any file that starts with a period in windows by appending a period to the filename... So create the file as
.htaccess.
and windows will strip the appended period and you end up with.htaccess
-
muhammad tayyab over 3 yearsinterestingly this solved my issue when I changed permalinks in wordpress having no .htaccess all I edited within httpd.conf file to get this worked for my localhost wordpress setup
-
Tiny Sonhh about 3 yearsThis is the only way resolved my rewrite rule issue. I've been struggling for a week just to fix this. You saved my day! Thank you a lot.
-
Ibrahim.H almost 3 yearsUsually after trying a garbage in the .htaccess to make sure it works, we start by checking
IfModule
is activated, then we add the simplest rule without any conditions (something likepath/page
todirect/url
) to make sure apache is working, then you can add your conditions one by one. -
Amila Senadheera over 2 yearsthis worked for me. Thanks a lot!