开发者

Mod_rewrite directory requests

开发者 https://www.devze.com 2023-04-07 13:41 出处:网络
I am trying to do this: example.com/directory/song.mp3 -> Unchanged example.com/directory/ -> example.com/?dir=directory%2F

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
0

精彩评论

暂无评论...
验证码 换一张
取 消