开发者

Problems with mod_rewrite and 301 redirects from one dynamic url to another

开发者 https://www.devze.com 2023-01-01 10:54 出处:网络
Hey all, I\'m having all kinds of problems with a bunch of apache redirects just now and could really use some help!

Hey all, I'm having all kinds of problems with a bunch of apache redirects just now and could really use some help!

I'm wating to put in a 301 redirect for a load of urls from a client's old site to their new site in the following format;

Old - page.php?pageNum_rs_all=0&totalRows_rs_all=112

New - page/sub?foo=bar

The values in the query sting for the old site don't in any way tie up to any ids or references on the new site, I only want to match that specific request and redirect to the new page.

It feels like I've tried just about every combination of rewriterule I can find online but still nothing seems to be working. This is running on Apache 2.2.

The rule I sta开发者_如何学Pythonrted with (and keep going back to) is;

RewriteRule ^/page.php\?pageNum_rs_all=0&totalRows_rs_all=112 /page/sub?foo=bar [R=301,L,NE]

Any help would be greatly appreciated!

c.


The reason that this doesn't work is that RewriteRule can't see the QueryString. To get at the Query String, you need to use RewriteCond. See http://wiki.apache.org/httpd/RewriteQueryString for examples of how this works.


I've always tended to use use a series of 301 redirects in the following manner

Redirect 301 /oldpage /newpage
0

精彩评论

暂无评论...
验证码 换一张
取 消