Mod_rewrite directory requests
I am trying to do this:
example.com/directory/song.mp3 -> Unchanged
example.com/directory/ -> example.com/?dir=directory%2F
example.com/ -> Unchanged
example.com/index.php -> Unchanged
Basically, if a user requests any directory other than root, I need it rewritten, not redirected, to index.php?dir=< path w开发者_开发技巧ith slashes changed to %2F>
I want the user to still see example.com/path/to/stuff in their browser, but the request to be rewritten serverside.
example.com/songs/stuff -> example.com/?dir=songs%2Fstuff%2F
I hope I am clear about what I am looking for.
try this:
RewriteRule ([^/]+/.*) /index.php?dir=$1
精彩评论