我想重定向此网址:
http://tops.domain.com/test
http://files.domain.com/css/style.css
http://domain.com/test
到这些:
/tops.php?what=test
/css/style.css
/index.php?username=test
我在.htaccess文件中编写了这些代码并将其放在root:
中Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^tops\. [NC]
RewriteRule .* tops.php?what=$0 [QSA,L,NC]
RewriteCond %{HTTP_HOST} ^files\. [NC]
RewriteRule .* $0 [NC,L,QSA]
RewriteRule .+ index.php?username=$0 [L,QSA]
但不能正常工作
答案 0 :(得分:0)
使用此.htaccess
:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^files\. [NC]
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} ^tops\. [NC]
RewriteCond %{REQUEST_URI} !^/tops\.php [NC]
RewriteRule .* tops.php?what=$0 [QSA,L,NC]
RewriteCond %{QUERY_STRING} !^username= [NC]
RewriteRule .+ index.php?username=$0 [L,QSA]