Matt Elhotiby
Matt Elhotiby

Reputation: 44066

Why is my htaccess rule not rewriting the url

Ok so i have this url in my opencart application and it works well

http://site.com/index.php?route=information/contact

but the clients hates the url and wants

http://site.com/contact

i figured i could just do this in my htaccess and all would be good but visiting the url i get nothing

RewriteRule ^(contact)$ index.php?route=information/contact  [L,QSA]

any ideas

here is my htacess

RewriteBase / 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

RewriteRule ^contact$ /index.php?route=information/contact  [L,QSA]

Upvotes: 0

Views: 2133

Answers (4)

Pedro Lobito
Pedro Lobito

Reputation: 98921

[OpenCart] Enable URL Rewriting for SEO

  1. Login into Admin Control Panel
  2. Select Admin > Configuration > Settings > Server
  3. Select “SEO URL” option to yes.
  4. You are done.

Upvotes: 2

Book Of Zeus
Book Of Zeus

Reputation: 49887

remove the parenthesis

RewriteRule ^contact$ index.php?route=information/contact  [L,QSA]

your .htaccess should look like:

RewriteEngine On
RewriteBase / 
RewriteRule ^contact$ /index.php?route=information/contact  [L,QSA]
RewriteCond %{REQUEST_URI} !^/contact$
RewriteRule ^([^?]*) index.php?route=$1 [L,QSA]

Upvotes: 4

Chris
Chris

Reputation: 1579

Is mod_rewrite enabled? Also, you might have to add

RewriteEngine on

before your RewriteRules

Upvotes: 2

ErJab
ErJab

Reputation: 6375

Try adding a / before index.php

RewriteRule ^contact$ /index.php?route=information/contact  [L,QSA]

Upvotes: 1

Related Questions