I have this url:
example.com/play.php?v=lorem-ipsum
want it to be:
example.com/play/lorem-ipsum
here is my try:
RewriteCond %{THE_REQUEST} \s/ play\.php\?v=([^\s&] ) [NC]
RewriteRule ^ /%1? [R=301,L,NE]
result:
example.com/lorem-ipsum
so play/
is missing
maybe because I have a folder named play
pls help
CodePudding user response:
so play/ is missing.
maybe because I have a folder named play
No, it is missing, because $1
contains only the part you actually captured with your regular expression, the part inside the (...)
.
You want RewriteRule ^ /play/%1? [R=301,L,NE]
(unless you wanted the play
part to also be dynamic, then you would have to capture whatever was in that place as well.)
maybe because I have a folder named play
That can cause additional problems though, if you still have MultiViews
activated, that should be deactivated in cases where you have such a partial overlap between "fake" URL, and actually existing files.