Reputation: 24468
What I'm trying to do is use the same URL with different query strings to go to two different pages.
What I have right now is a URL's that looks like this
http://mysite.com/embed?a=somestring
and http://mysite.com/embed?b=somestring
I need to get a rewrite rule that will redirect both to two different URL's depending on if the query var is a or b
This below works but it matches both URL's and sends it to the one link
RewriteRule ^embed$ index.php?page=embeda [QSA]
If I do these two it doesn't work and will always match the first one.
RewriteRule ^embed$ index.php?page=embeda [QSA]
RewriteRule ^embed$ index.php?page=embedb [QSA]
Not sure how to do two different rewriterules for this.
Upvotes: 1
Views: 289
Reputation: 3692
Use a RewriteCond directive and examine the %{QUERY_STRING}
.
RewriteCond %{QUERY_STRING} \ba=
RewriteRule ^embed$ index.php?page=embeda [QSA]
RewriteCond %{QUERY_STRING} \bb=
RewriteRule ^embed$ index.php?page=embedb [QSA]
RewriteCond is really just a conditional, an if statement. Note the \b
bit in the pattern, it's a word boundary. I put it there to make sure it works even if there are other query string parameters before 'b'.
Upvotes: 1