试图让 mod_rewrite 工作
我在将 CMS 从旧的 CMS 切换到新的 CMS 时遇到了这个问题,因此我尝试正确重定向 url。
以下是我想要转换的一些示例网址:
#-1) http://www.mysite.com/?dispatch=search_data&features=hash_tag
#-2) http://www.mysite.com/index.php?dispatch=search_data&features=hash_tag
基本上,它们都是相同的,只是第一个网址中没有 index.php。
我得到以下代码以部分工作:
RewriteCond %{QUERY_STRING} dispatch=(.*)
RewriteRule ^$ http://www.mysite.com/? [L,R=301]
上面的代码适用于#-1(当没有index.php时),但是当有index.php时它不起作用。
非常感谢任何帮助/指导。
谢谢
____________ 更新____________ ___
根据请求,目标网址应如下: http://www.mysite.com/
I have this problem where I switched CMS from the old one to the new one so I am trying to redirect urls properly.
Here are some example urls I wanted to convert:
#-1) http://www.mysite.com/?dispatch=search_data&features=hash_tag
#-2) http://www.mysite.com/index.php?dispatch=search_data&features=hash_tag
Basically both of them are identical except the first one doesn't have index.php in the url.
I got the following to code to partially work:
RewriteCond %{QUERY_STRING} dispatch=(.*)
RewriteRule ^$ http://www.mysite.com/? [L,R=301]
The above code works for #-1 (when there is no index.php) but when there is index.php it doesn't work.
Any help / guidance is much appreciated.
Thanks
____________UPDATE_______________
As per request, here is what the the target url should be:http://www.mysite.com/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你说它“有效”是什么意思?
您可能应该发布一个示例,说明您希望新 url 在给定旧 url 的情况下是什么样子。
但无论如何,您的部分问题是
RewriteRule
行明确排除了index.php
以及您网站上的任何其他页面。你写的基本上可以翻译成这样:
What do you mean it "works"?
You should probably post an example of what you want the new url to look like given the old url.
But in any case, part of your problem is that the
RewriteRule
line is specifically excludingindex.php
and any other page on your site.What you wrote basically tranlates to this:
您是否尝试过更改第二部分以包含“index.php”部分?
have you tried changing the second part to include the "index.php" part?