I am not able to get URL redirection to work. It appears to be a problem with my .htaccess
file. I am using WampServer.
Following is the code in .htaccess:
RewriteEngine on RewriteRule ^contactus index.php?file=c-contactus
I am not able to get URL redirection to work. It appears to be a problem with my .htaccess
file. I am using WampServer.
Following is the code in .htaccess:
RewriteEngine on RewriteRule ^contactus index.php?file=c-contactus
put a / before index.php?file=c-contactus
so it becomes:
/index.php?file=c-contactus
or
RewriteRule ^contactus$ index.php?file=c-contactus
You must enable RewriteRule at first step.
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Change the AllowOverride None to AllowOverride All
in /etc/apache2/sites-enabled/000-deafult
Please make sure you have mod_rewrite module enabled in your Apache server configuration first. One of the easiest way is to run a phpinfo() and look in Loaded Modules section as below:
If you did't find the mod_rewrite there, edit the httpd.conf file in /wampserver/bin/apache/conf path and uncomment the following line:
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
RewriteBase /your-project-folder/
RewriteRule ^contactus/?$ index.php?file=c-contactus [L,QSA]
If you working with localhost then please provide root folder name(In which your project avaiable) for url rewritebase
For example: If your index.php file under the firstproject folder then set like this
RewriteEngine on
RewriteBase /firstproject/
RewriteRule ^contactus/?$ index.php?file=c-contactus [L,QSA]