为什么我的htaccess规则不重写网址

编程入门 行业动态 更新时间:2024-10-23 23:22:23
本文介绍了为什么我的htaccess规则不重写网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

site/index.php?route=information/contact

但客户讨厌该网址并想要

but the clients hates the url and wants

site/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规则不重写网址

本文发布于:2023-11-16 18:20:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606687.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   规则   网址   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!