【问题标题】:Redirect variable page to variable subdomain wildcard将变量页面重定向到变量子域通配符
【发布时间】:2012-02-20 20:04:09
【问题描述】:

我陷入了跟随 htaccess 的情况。

我想将页面重定向到子域。

现在的网址示例;

http://domain.tld/user/foo

我需要将其重定向到;

http://foo.domain.tld

子域由通配符生成。

我尝试了以下但没有成功;

RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$
RewriteRule (.*) s/index.php?user=%1 [NC,QSA] 
RewriteRule ^user/(.*) (.*) [R=301,L]

问候,

尼克

【问题讨论】:

  • 您是否为每个用户设置了子域?
  • 它是通过通配符 ('*.domain.tld') 实现的动态,因此只有一个子域可以捕捉所有可能。

标签: .htaccess redirect subdomain


【解决方案1】:
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$
RewriteRule (.*) s/index.php?user=%1 [NC,QSA]

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.tld [NC]
RewriteRule ^user/([a-zA-Z0-9-.]+) http://$1.domain.tld/ [R=301,L]

【讨论】:

  • 嗯,没有成功,但也不是内部服务器错误。
猜你喜欢
  • 2012-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-20
  • 2018-10-22
  • 2014-02-09
  • 2021-08-08
相关资源
最近更新 更多