Hi All,
I am trying to use the RewriteRule correctly but cant seem to get it right. I know the RewriteRule has been discussed many times on this forum but none quite like what I am trying to do. I am using my apache2 vhost file and not .htaccess.
I would like to redirect the following requests only to strip away the ?
http://example.com/?advert_state=1 --> /property-for-sale
http://example.com/?advert_state=2 --> /property-for-rent
So if the url has state=1 strip the ? redirect to the correct url and the same for state=2. I have tried to escape the ? like this \? but that didn't work. I read somewhere else to use [?] to escape a regular expression too. This works but always goes to the second url. My rule currently is as follows:
RewriteEngine On
RewriteRule ^/[?]advert_state=1 /property-for-sale [R=301,L]
RewriteRule ^/[?]advert_state=2 /property-for-rent [R=301,L]
This always goes to /property-for-rent and ignores the first one. I would really appreciate any help.
Regards