Reputation: 1397
Basically, I am sent a query string that I need to reformat into a URL where the values are divided by slashes and where the dots are cleared out of one of the values. I can do either of those things, but when I try to chain them together it doesn't work.
Here is the original URL
https://www.example.com/?id1=5&id2=7&id3=9&id4=7&id5=source.website.com&id6=5
Here is what I have right now ...
# Takes the dots and replaces name of server
RewriteCond %{QUERY_STRING} ^(.*source.website.com.*)$
RewriteCond %{QUERY_STRING} (.*id5=).*(id6=.*)$
RewriteRule ^(.*) %1newwebsitecom&%2?
# Rewrites Query to URL
RewriteCond %{QUERY_STRING} ^id1=(\w+)&id2=(\w+)&id3=(\w+)&id4=(\w+)&id5=([a-zA-Z0-9\.\%]+)&id6=(\w+)
RewriteRule ^(.*) https://www.example.com/dir/%1/%2/%3/%5/%6?
Separately, both of these work. However, the second rule simply takes the query and performs the actions as if the first never took place. How do I get around that?
Upvotes: 1
Views: 25
Reputation: 450
Have you tried merging the two rules?
I've tested this rule set on htaccess.madewithlove.be and it seems to achieve the desired results.
RewriteCond %{QUERY_STRING} ^(.*source.website.com.*)$
RewriteCond %{QUERY_STRING} (.*id5=).*(id6=.*)$
RewriteCond %{QUERY_STRING} ^id1=(\w+)&id2=(\w+)&id3=(\w+)&id4=(\w+)&id5=([a-zA-Z0-9\.\%]+)&id6=(\w+)
RewriteRule ^(.*) https://www.example.com/dir/%1/%2/%3/%4/newwebsitecom/%6?
Upvotes: 1