Hi all,
This question builds on this thread ([
webmasterworld.com ]), which is now closed for replies.
I'm trying to move the files for a given subdomain into a subfolder. I'd like to rewrite the new path with .htaccess, while not exposing the "true" server path, even when a folder URL is entered without a trailing slash. I went with the following solution, adapted from the thread linked above:
# Externally redirect to add trailing slash to extensionless URLs if missing
RewriteCond %{HTTP_HOST} ^test.example.com$ [NC]
RewriteRule ^(([^/]+/)*[^./]+)$ http://test.example.com/$1/ [L,R=301]
# Internally rewrite all requests to subfolder
RewriteCond %{HTTP_HOST} ^test.example.com
RewriteRule ^(.*)$ /subfolder/$1 [L,NC,QSA]
This works great - with one exception. If I enter a URL like:
http://test.example.com/my-script?xdm_e=https%3A%2F%2Fjk.test
it gets redirected to
http://test.example.com/my-script/?xdm_e=https%253A%252F%252Fjk.test
Note in addition to adding the trailing slash (as desired), percent symbols have also been expanded to "%25". This is what I'd like to avoid. After lots of googling, I thought this might have something to do with the "B" flag, but adding that to the RewriteRule just made things worse ("my-script" got changed to "my%252dscript", and the percents were still altered).
Any pointers would be greatly appreciated - I've been tinkering with this for hours, but am pretty unfamiliar with mod_rewrite.