1

我正在处理一个带有 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]

提前致谢

4

1 回答 1

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]
于 2014-11-18T12:46:26.243 回答