1

I'm trying to do a very simple redirect. We're moving from a standalone Wordpress install to a Multisite Wordpress install, and I'm trying to get the redirect working for a page with query strings. Here's the code I have so far:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^advise/index_pt(.*)$ http://domain.com/advise/pennies-to-millions/$1 [NE,L,R=301]

Basically, this is what I want: (with or without www)

*.domain.com/advise/index_pt.php?(parameters) => *.domain.com/advise/pennies-to-millions/?(parameters)

Any help is appreciated!

1
  • Take a look at the QSA-flag, maybe this will help you Commented Jun 11, 2012 at 15:59

1 Answer 1

2

Query strings aren't part of the URI used to match in a RewriteRule directive. So you can't use a regular expression to match against them inside a RewriteRule. If you needed to match against them, you can use a RewriteCond %{QUERY_STRING} <regex> before the rule. However, query strings are automatically appended anyways if you don't create any new ones by using a ? in the rule's target. You can remove all the backreferences in the rule and add parens around the www to make them optional.

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^advise/index_pt.php$ http://domain.com/advise/pennies-to-millions/ [NE,L,R=301]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.