简体   繁体   中英

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 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.

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. But you can do so with mod_rewrite :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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