我正在处理一个包含3个参数的.htaccess文件,但它也适用于1个参数或2个参数。我有2个参数的样本,但我无法弄清楚如何使用3个参数。
这是我的代码:
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&]+)&lang=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?key=$2&lang=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?key=$1 [L,QSA]
提前致谢
答案 0 :(得分:1)
我通过模仿上面的代码找到了答案
以下是新版本:
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&]+)&lang=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?key=$2&lang=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?key=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&]+)&lang=([^&\ ]+)&extra=([^&]+)
RewriteRUle ^ /%1/%2/%3? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ index.php?key=$2&lang=$1&extra=$3 [L,QSA]