0
我需要將通配符子域選項與尾隨信息重定向到2個單獨的php變量中。htaccess子域名和目錄重定向
舉例來說。 http://company.domain.com/xyz
需要去
http://domain.com/redirect.php?url=xyz&user=company
我使用的是短URL重定向,以及他們目前正在使用下列htaccess的命令:
RewriteCond %{REQUEST_URI} ^(.+)\!$
RewriteRule ^(.*) stats.php?url=$1 [L]
RewriteCond %{REQUEST_URI} ^(.+)\~s$
RewriteRule ^(.*) stats.php?url=$1 [L]
RewriteCond %{REQUEST_URI} ^(.+)\~q$
RewriteRule ^(.*) generate_qr.php?url=$1 [L]
RewriteCond %{REQUEST_URI} ^(.+)\~p$
RewriteRule ^(.*) preview_url.php?url=$1 [L]
RewriteCond %{REQUEST_URI} !^(.+)\.html$
RewriteCond %{REQUEST_URI} !^(.+)\.htm$
RewriteCond %{REQUEST_URI} !^(.+)\.php$
RewriteCond %{REQUEST_URI} !^(.+)\.js$
RewriteCond %{REQUEST_URI} !^(.+)\.css$
RewriteCond %{REQUEST_URI} !^(.+)\.jpg$
RewriteCond %{REQUEST_URI} !^(.+)\.png$
RewriteCond %{REQUEST_URI} !^(.+)\.gif$
RewriteCond %{REQUEST_URI} !^(.+)\.swf$
RewriteCond %{REQUEST_URI} !^(.+)\.xml$
RewriteCond %{REQUEST_URI} !^(.+)\.ico$
RewriteCond %{REQUEST_URI} !^(.+)\.txt$
RewriteCond %{REQUEST_URI} !^index\.html$
RewriteCond %{REQUEST_URI} !^index\.php$
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) url_redirector.php?url=$1 [L]
RewriteRule ^(.*).html$ $1.php [L]
所以我需要添加類似
RewriteCond %{HTTP_HOST} ^([^/.]+)\.domain\.com/$
RewriteRule ^(.*) url_redirector.php?url=$1&user=%1 [L]
W這裏的「用戶」是子域的值,同時保持重定向器的條件重寫。這將如何完成?
注意,這裏假設你的主機尚未翻譯的網址(例如)'http://domain.com/company/original_URI'。在這種情況下,您必須從'%{REQUEST_URI}'中選擇「公司」。 –