.htaccess 如何使用多个查询参数重定向动态子域
我想重定向.htaccess 如何使用多个查询参数重定向动态子域,.htaccess,.htaccess,我想重定向 domain.com/test.php?username=username&code1=849&code2=4d1 username.domain.com/849/4d1 到 使用.htaccess 目前我有 RewriteRule ^test/([^/]+)/([^/]+)/([^/]+) test.php?username=$1&code1=$2&code2=$3 [NC] RewriteCond %{HTTP_HOST} ^(^.*)\.do
domain.com/test.php?username=username&code1=849&code2=4d1
username.domain.com/849/4d1
到
使用.htaccess
目前我有
RewriteRule ^test/([^/]+)/([^/]+)/([^/]+) test.php?username=$1&code1=$2&code2=$3 [NC]
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule ^(.*) test.php?username=%1&code1=%2&code2=%3 [NC]
重定向可以工作,但代码(php)
是空的。谁能给我指出正确的方向吗
谢谢你找到了
所以如果你想重定向
domain.com/test.php?username=username&code1=849&code2=4d1
username.domain.com/849/4d1
到
您需要将以下代码添加到.htaccess文件中:
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule ^(.*)/([^/]+) test.php?username=%1&code1=$1&code2=$2 [NC]
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule ^(.*)/([^/]+) test.php?username=%1&code1=$1&code2=$2 [NC]