apache - RewriteRule expression not working -
i want rewrite url another, rewrite expression not working.
ex. url1: "http://www.demo.com/de-ch/case1/?id=23"
and
ex. url2: 'http://www.demo.com/de-ch?id=23'
rule: rewriterule ^(.....)([\?]|(.*))$ http://www.result.com/$1 rule gives follow result:
http://www.result.com/de-ch?id=23 but need iso codes http://www.result.com/de-ch
what missing in regex?
you can't match against query string in rule's pattern. query string isn't technically part of path. you'll need use rewritecond , %{query_string} variable:
rewritecond %{query_string} ^id=23 rewriterule ^(.....) http://www.result.com/$1? note "?" @ end of rule's result. remove query string.
however, since you're not doing query string, can leave out entirely , have:
rewriterule ^(.....) http://www.result.com/$1? note rule cause browser redirected http://www.result.com/de-ch , if don't have resource resolves @ url, you'll 404 or related error.
Comments
Post a Comment