Need Regex Help For Complicated Query String

sharingsunshine used Ask the Experts™
I need some mod rewrite help with a regex.  This is an example url -

I am trying to get it to redirect to the url after the last equals sign -

I have 2,000 links like this all with a different url after the last equals sign.

Here is my code

RewriteCond %{REQUEST_URI} /?12all/lt\.php$
RewriteCond %{QUERY_STRING} c=(.*)$ [NC]
RewriteCond %{QUERY_STRING} m=(.*)$ [NC]
RewriteCond %{QUERY_STRING} nl=(.*)$ [NC]
RewriteCond %{QUERY_STRING} s=(.*)$ [NC]
RewriteCond %{QUERY_STRING} lid=(.*)$ [NC]
RewriteCond %{QUERY_STRING} l=-http--(.*)$ [NC]
RewriteRule ^.*$ https://%6/? [NC,L,R=301]

Open in new window

Please tell me what I am doing wrong so I can get this cleaned up for Google.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Consultant & Challenge Subduer
Top Expert 2009
I find the documentation helpful. It looks to me that the back reference numbering is incorrect. Try "%1" instead of "%6".

It's recommended to use 302 redirects during testing and switch to 301s only after it's working correctly.

BTW, is checking for the presence of the other parameters necessary?


that fixed it.  So you count back references from the bottom?  How would I do it different since I don't need to check for the presence of the other parameters?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial