为什么我的htaccess规则不是重写URL
好了,所以我在Opencart的应用程序中有这个网址,并运作良好为什么我的htaccess规则不是重写URL
http://site.com/index.php?route=information/contact
但客户不喜欢的网址,并希望
http://site.com/contact
我想通我可以做到这一点在我的htaccess以及一切都会好的,但访问URL我得到什么
RewriteRule ^(contact)$ index.php?route=information/contact [L,QSA]
任何我DEAS
这里是我的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]
删除括号
RewriteRule ^contact$ index.php?route=information/contact [L,QSA]
你的.htaccess应该是这样的:
RewriteEngine On
RewriteBase/
RewriteRule ^contact$ /index.php?route=information/contact [L,QSA]
RewriteCond %{REQUEST_URI} !^/contact$
RewriteRule ^([^?]*) index.php?route=$1 [L,QSA]
奇怪...但仍没有 – Trace
这就是我对我的服务器做,你就把:RewriteEngine叙述在这个规则的权利过吗?你之前有什么规则? –
您需要:RewriteEngine叙述在之前RewriteBase/ –
尝试添加/ index.php的前
RewriteRule ^contact$ /index.php?route=information/contact [L,QSA]
我看到问题了RewriteRule ^([^?] *)index.php?_route _ = $ 1 [L, QSA] 正在引发问题...有没有办法做到这一点,除了联系 – Trace
是否启用了mod_rewrite?此外,您可能有你的RewriteRules之前添加
RewriteEngine on
[OpenCart] Enable URL Rewriting for SEO
- 登录到管理控制面板
- 选择管理>配置>设置>服务器
- 选择“SEO网址”选项是。
- 你完成了。
我有一个冲突的规则RewriteRule ^([^?] *)index.php?_route _ = $ 1 [L,QSA]我可以有这个规则,但添加一个除了联系所以另一个规则可以工作 – Trace
这个冲突的规则搞乱了一切,我已经更新了答案,你可以尝试新的解决方案吗? –
当您访问http://site.com/contact会发生什么?一个404? – ErJab
如果是这样,请检查你的Apache的错误日志。它会告诉你它到底是什么试图寻找并不能找到.. – ErJab
是显示一个404页, – Trace