.htaccess 中的 RewriteRule 后重复附加 URL?
这是我第一次为了 SEO 友好而重写 url。
这是我的 htaccess 规则:
RewriteEngine On
RewriteRule ratings/ ratings.php
RewriteRule regions/ regionlist.php
RewriteRule mobile/ mobile.php
出于某种原因,当我单击同一个链接两次时,该 url 会在地址栏中追加自身。这是一张 gif 图片,显示了这种情况:
这很糟糕吗?如果是,有人知道出了什么问题吗?
帮助将不胜感激!
谢谢大家
This is my first time re-writing urls to be SEO friendly.
Here's my htaccess rule:
RewriteEngine On
RewriteRule ratings/ ratings.php
RewriteRule regions/ regionlist.php
RewriteRule mobile/ mobile.php
For some reason, when I click the same link twice, the url will append itself in the address bar. Heres a gif image showing this happening:
Is this bad? If it is, does anyone know what's wrong ?
Help would be greatly appreciated!
Thanks everyone
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将您的 RewriteRules 更改为:
并确保您的链接如下所示:
但如果您需要特定重写,请更改斜杠的位置
Change your RewriteRules to this:
and make sure that your links to be like this:
but if you need specific rewrites change the location of slash
我认为这不是 htaccess 造成麻烦的地方...在我看来,您获取当前 URL 并附加单击项目的名称。相反,请从头开始创建 URL。
I think it's not the htaccess which couses trouble here... IMO you take current URL and append clicked item's name. Create the URL from scratch instead.
如果您希望重写始终基于根目录,您可能需要在规则中添加前面的“/”(斜杠),
这将强制重写规则将其附加到根 url。
if you want the rewrite to always be based off the root directory you may want to write your rules with a preceeding "/"(slash)
This should force the rewrite rule to append this to the root url.
使用重定向:
Use redirect: