我正在使用下面的代码来重定向下面的网址:
到
www.example.com/index.php?cod=100
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?cod=$1 [L]
它可以工作,但是如果我想重定向这个网址怎么办:
至:
您需要在您已有的规则之前添加另一个规则来处理这个更具体的请求。类似这样的东西:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# https://www.example.com/100/200
RewriteRule ^(\d+)/(\d+)/?$ index.php?cod=$1&othercod=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# https://www.example.com/100
RewriteRule ^(\d+)/?$ index.php?cod=$1 [L]