.htaccess - Rewrite rule to hide folder, doesn't work right without trailing slash -
i have strange apache mod_rewrite problem. need hide sub-directory user, redirect every request sub-directory. found several quite similar issues on stackoverflow, nothing fits, decided post new question.
my .htaccess looks this:
rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_filename} !-l rewriterule ^(.*)?$ foo/$1 [qsa,l]
the document-root contains following folder/files:
/foo/bar/index.html
i expect example.com/bar , example.com/bar/ show me contents of index.html.
instead example.com/bar/ show me content expected example.com/bar redirects me 301 example.com/bar/foo/ shows contents. don't why there 301 redirect in case.
when put
rewritecond %{request_uri} !^[^.]*/$ rewritecond %{request_uri} !^[^.]*\.html$ rewritecond %{request_uri} !^[^.]*\.php$ rewriterule ^(.*)$ $1/ [qsa,l]
on top of rule seems work, require me list every used file extension...
is there other way can omit redirect, folder "bar" should never seen outside user.
thanks in advance!
1st rewrite rule redirect /foo/(.) ($1) , second - (.) $1.
just idea, has not been tested.
Comments
Post a Comment