Apache URL重写&所有请求都由同一个PHP文件运行


Apache URL Rewrite & All requests run by same PHP file

我不知道这是可能的还是真的很奇怪,但这就是。我需要帮助

1)为用户文件夹做Apache URL重写:/basepath/组/用户/应用程序/

2)所有的请求必须由同一个PHP脚本处理
/somepath/index.php

3)这里是catch,我需要PHP脚本访问组,用户和应用程序,如

http://www.somehost.com/usergroup/username/userapp/

应该执行

http://www.somehost.com/index.php

但等于

http://www.somehost.com/index.php?grp=usergroup&usr=user&app=app

我希望这是有意义的,提前感谢!!!!

OOO经过深思熟虑!基本上所有的请求说域是由相同的PHP脚本和路径转换成URI变量处理?明白了吗?

你可以在你的root .htaccess文件中使用这个规则:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /index.php?grp=$1&usr=$2&app=$3 [L,QSA]

RewriteRule ^([^/]+)/([^/]+)/([^/]+)组。/index . php ? = 1美元,用户= 2美元,应用= 3美元(NC)

这工作。我的实际版本是:

######LOCALHOST (in house dev)
RewriteRule ^apps/([^/]+)/([^/]+)/([^/]+) ./index.php?pub=$2&app=$3&bld=$4 [NC,L]
RewriteRule ^apps/([^/]+)/([^/]+) ./index.php?pub=$2&app=$3&bld=release [NC]
######PRODUCTION (remote production)
RewriteRule ^([^/]+)/([^/]+)/([^/]+) ./index.php?pub=$1&app=$2&bld=$3 [NC,L]
RewriteRule ^([^/]+)/([^/]+) ./index.php?pub=$1&app=$2&bld=release [NC]