我在每个子文件夹项目特定的文件中都有一个带有apache的.htaccess文件。 示例 http://www.website.com/projecta/subfolder/.htaccess
使用apache,重写这不是问题,现在使用nginx似乎并不那么明显:
旧.htaccess:
RewriteEngine on<br/>
RewriteCond %{REQUEST_FILENAME} !-f<br/>
RewriteCond %{REQUEST_FILENAME} !-d<br/>
RewriteRule ^(.*)$ index.php?rt=$1
我尝试了几个选项,但似乎没有一个接受结构:
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?rt=$1 break;
}
}
备注:每个子文件夹都有一个.htaccess文件,而此配置是全局级别的。我不知道每次如何解析projecta/subfolder/
。
你能试试下面吗
location / {
rewrite ^/([^/]+)/([^/]+)/(.*)$ /$1/$2/index.php?rt=$3 break;
}