I am using Apache 2.4.7
. I use mod_rewrite
to alter some urls.
I want to rewrite http://example.com/servicename/oldpage?id=abc
to http://example.com/servicename/newpage
.
Other similar rewrites work so I belive the ?
inside url is causing problems.
I have tried escaping it with \
.
This works as there is no ?
in url:
RewriteRule ^/servicename/old /servicename/new
But these don't work:
RewriteRule ^/servicename/oldpage?id=abc /servicename/newpage
RewriteRule ^/servicename/oldpage\?id=abc /servicename/newpage
I have also tried using RewriteCond
from examples like this: .htaccess rewrite URL with a question mark "?" but I didn't manage to get them work.
How should rewrite url that contains question mark?
EDIT: I tried solutions given in Match Question Mark in mod_rewrite rule regex but was not able to make them work for me. That question is about preserving query string when rewrite while I want to remove it when rewriting.