为什么我的htaccess规则不重写网址 [英] Why is my htaccess rule not rewriting the url

查看:58
本文介绍了为什么我的htaccess规则不重写网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我在我的opencart应用程序中有这个网址,并且效果很好

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

我认为我可以在htaccess中执行此操作,一切都会很好,但是访问url却一无所获

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]

任何想法

这是我的努力

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文件应如下所示:

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]

这篇关于为什么我的htaccess规则不重写网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆