Link to home
Start Free TrialLog in
Avatar of sharingsunshine
sharingsunshineFlag for United States of America

asked on

Need Regex To Handle Double Question Marks

I have several 404 links that need to be redirected.  They are from an external source so I don't have the control to change the links.  So I am wanting a rewrite rule for htaccess I can use.

Here is a sample of the original link:  http://www.abc.com/index.php?controller=product?pageid=444

Here is what it should look like:  http://www.abc.com/index.php?controller=product&id_product=444

This is the rewrite I am trying but it doesn't match.  Neither does the other option which escapes the ? in the rewrite rule.

RewriteCond %{QUERY_STRING} ^controller=product?pageid=444$ [NC]
RewriteRule ^/index\.php$ /index.php?controller=product&id_product=444? [R=301,L]

RewriteCond %{QUERY_STRING} ^controller=product?pageid=444$ [NC]
RewriteRule ^/index\.php$ /index.php\?controller=product&id_product=444? [R=301,L]

Please tell me what I am doing wrong in the regexes I have.

Thanks,
Avatar of ozo
ozo
Flag of United States of America image

Did you try escaping the ? in RewriteCond?
Avatar of sharingsunshine

ASKER

I just now tried it but there was no change.  So I then escaped the ? in the rewrite rule and that made no difference either.
SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I hope you want to redirect 404 pages only.

RewriteEngine on
ErrorDocument 404 /index.php
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial