I have URLs like the following:
mysite.com/eng?sentence=dog
and I want to rewrite them as
mysite.com/eng/dog
so I want to replace ?sentence=
with a "/"
I have tried all of the following:
RewriteCond %{THE_REQUEST} ^GET\ sentence= [NC]
RewriteRule ^ /%1 [NC,L,NE]
RewriteCond %{THE_REQUEST} ^GET\ \?sentence= [NC]
RewriteRule ^ /%1 [NC,L,NE]
RewriteCond %{THE_REQUEST} ^GET\ \?sentence=([^/?&\s]+) [NC]
RewriteRule ^ /%1 [NC,L,NE]
RewriteCond %{THE_REQUEST} ^GET\s/+\?sentence=([^/?&\s]+) [NC]
RewriteRule ^ /%1 [NC,L,NE]
then I tried accessing the URL:
mysite.com/eng?sentence=cat
but it stays as it is. I assume my regex logic is not correct and the rewrite cond is never satisfied. I always have trouble with regex.
You can use this rule:
This will redirect
http://mysite.com/eng?sentence=dog
intohttp://mysite.com/eng/dog/