WAMP/XAMPP Server- .htaccess redirect rule not working on localhost

Sometimes developer facing the issue that redirects rule is not working on the local machine and get the message like…

Not Found

The requested URL was not found on this server.

Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80

See the sample redirect rule in .htaccess file which removes the .php extension from the URL.

RewriteEngine On

# .php to extension less
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(([^/]+/)*[^.]+)$ $1.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php http://www.localhost/$1 [R=301,L]


WAMP Server

If you are using wamp server you need to modify the Apache configuration file httpd.conf

  1. Go to the C drive/wamp installation location » wamp » bin » apache » apache2.4.9 » conf » httpd.conf
  2. In the Directory tag, update AllowOverride to all (default none)
<Directory "c:/wamp/www/">
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    AllowOverride all

XAMPP Server

Modify the same above configuration in xampp server also. You can find httpd.conf file at this location.

Location: C drive/xampp installation location » xampp » apache » conf » httpd.conf

Similar Posts

About the Author

Atul Rai
I love sharing my experiments and ideas with everyone by writing articles on the latest technological trends. Read all published posts by Atul Rai.