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.
.htaccess
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]Solution
WAMP Server
If you are using wamp server you need to modify the Apache configuration file httpd.conf
- Go to the C drive/wamp installation location » wamp » bin » apache » apache2.4.9 » conf »
httpd.conf - In the
Directorytag, updateAllowOverridetoall(default none)
httpd.conf
<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
</Directory>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
- IntelliJ IDEA- Generate Getter & Setter Shortcut Key
- svn: There are unfinished transactions detected
- The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- IntelliJ IDEA – System.out.println shortcut
- How to increase console buffer size in Eclipse/STS
- How to change default Author and Committer in Eclipse Git plugin?
- Maven- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
- How to resize image dimension in Photoshop
- How to redirect from HTTP to HTTPS on Tomcat Server
- How to import Gradle project in Eclipse/STS