开发者

how can i avoid and allow subdirectories in htaccess

开发者 https://www.devze.com 2023-01-22 16:18 出处:网络
I want the following开发者_开发技巧 url http://www.mydomain.com/user.php?id=username to http://www.mydomain.com/username

I want the following开发者_开发技巧 url

http://www.mydomain.com/user.php?id=username

to

http://www.mydomain.com/username

via .htaccess...

i also want to avoid subdirectory name conflict.... where i have a rewrite rule i.e

RewriteRule ^home/$ home.php?id=$1 [NC,L]

so my url become http://www.mydomain.com/home/ so i want this home to be ignored...in http://www.mydomain.com/username


Rewrite rules are evaluated in the order they appear. So just put your home rewrite rule first, and your username rewrite rule second, like this:

RewriteRule ^home/(.*)$ home.php?id=$1 [NC,L]

RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^user.php$ $1 [NC,L]
0

精彩评论

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