我需要将带有尾随信息的通配符子域选项重定向到2个单独的php变量中。
所以举个例子。 http://company.domain.com/xyz
需要去
http://domain.com/redirect.php?url=xyz&user=company
我正在使用短网址重定向器,他们目前正在使用以下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]
"用户"是子域的值,同时保持重定向器的条件重写。怎么会这样做?
答案 0 :(得分:0)
将此规则作为第一条规则:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http:domain.com//redirect.php?url=$1&user=%1 [L]