URL rewriting on Linux Apache and wamp
For rewriting url on Centos Please do these steps.- First go to '/etc/httpd/conf/httpd.conf' and for wamp left click on wamp icon and go to Apache then httpd.conf and uncomment - #LoadModule rewrite_module modules/mod_rewrite.so and #AddModule mod_rewrite.c, so do so please remove trailing #.
- Now Edit directory section in this file for directory /var/www/html and change 'AllowOverride none' to 'AllowOverride All'.
Eg.
Options Indexes FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
;
TO
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
; - Now make a file in server root directory '/var/www/html' name .htaccess and write these line in this
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*).php$ $1.html [NC]
RewriteRule ^(.*).html$ $1.php [NC]
4-Now this will replace php extension in your file to .html extension so now if you want to open index.php then write only http://url/index.html only instead of http://url/index.php