问题
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]
回答1:
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]
回答2:
Is mod_rewrite enabled? Also, you might have to add
RewriteEngine on
before your RewriteRules
回答3:
[OpenCart] Enable URL Rewriting for SEO
- Login into Admin Control Panel
- Select Admin > Configuration > Settings > Server
- Select “SEO URL” option to yes.
- You are done.
回答4:
Try adding a / before index.php
RewriteRule ^contact$ /index.php?route=information/contact [L,QSA]
来源:https://stackoverflow.com/questions/7184712/why-is-my-htaccess-rule-not-rewriting-the-url