简体   繁体   English

.htaccess中带有查询字符串的简单301重定向不适用于Redirect指令

[英]Simple 301 redirect in .htaccess with query string does not work with Redirect directive

I am trying to redirect a single URL in a .htaccess file with Redirect : 我正在尝试使用Redirect .htaccess文件中的单个URL:

Redirect 301 /index2.php?option=com_rss&feed=RSS2.0&no_html=1 /something/somethingelse/

I have a bunch of other similar rules which work using directory structure URLs, but this one refuses to get processed. 我还有很多其他类似的规则,它们使用目录结构URL起作用,但是该规则拒绝得到处理。

Redirect 301 /old/url/ /new/url/

Do I have to do anything special? 我需要做些特别的事情吗?

Thanks! 谢谢!

With Redirect you can only test for URL paths , or more specifically, URL path prefixes but not for the URL query. 使用Redirect您只能测试URL路径 ,或更具体地说,是URL路径前缀,而不能测试URL查询。 But you can do so with mod_rewrite : 但是您可以使用mod_rewrite来做到这一点:

RewriteEngine on
RewriteCond %{QUERY_STRING} =option=com_rss&feed=RSS2.0&no_html=1
RewriteRule ^index2\.php$ /something/somethingelse/? [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM