0

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
Sean Bright
  • 118,630
  • 17
  • 138
  • 146

6 Answers6

3
RewriteRule ^/?contactus(/)?$ index.php?file=c-contactus
Matthew Rapati
  • 5,648
  • 4
  • 28
  • 48
2

put a / before index.php?file=c-contactus

so it becomes:

/index.php?file=c-contactus

or

RewriteRule ^contactus$ index.php?file=c-contactus
1

Try:


RewriteRule ^/contactus(.*) /index.php?file=c-contactus
vh.
  • 147
  • 1
  • 1
  • 6
0

You must enable RewriteRule at first step.

Look at here

<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

Community
  • 1
  • 1
Huseyin
  • 1,499
  • 2
  • 25
  • 39
0

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: enter image description here

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

ironcladgeek
  • 1,130
  • 1
  • 14
  • 14
0
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]
Hiren Raiyani
  • 754
  • 2
  • 12
  • 28