Forum Moderators: phranque
RewriteCond %{QUERY_STRING}^(.*)htmlInclude=(.*)&(.*)$ [OR]
RewriteCond %{QUERY_STRING}^(.*)htmlInclude=(.*)$
RewriteRule ^/path/to/filehttp://localhost/html/%2.html? [R=301,L]
url going in:
[localhost...]
url coming out:
[localhost...]
url I want:
[localhost...]
Ok, so first off my rule is removing the first part of the query string up until the htmlInclude part, but then after that it is only removing the last variable, but I want it to remove any variables that show up after the htmlInclude part. Even if there is just 1 which will work, or if there is as many as 5 or more. I have done a lot of looking and I don't get why this doesn't work, I assumed my first RewriteCond would take everything after the htmlInclude=htmlFile& and then I could just throw that away, but it only takes the last variable. Any pointers on what I could be doing wrong would be greatly appreciated, Thanks
RewriteCond %{QUERY_STRING} &?htmlInclude=([^&]+)
RewriteRule ^/path/to/file http://localhost/html/%1.html? [R=301,L]
Again, the ".*" pattern is apparently-easy to use, but often causes undesired side effects. Avoid it and use specific patterns whenever possible.
Jim