【问题标题】:.htaccess Redirect all Subdomains to an URL.htaccess 将所有子域重定向到一个 URL
【发布时间】:2018-07-18 01:12:03
【问题描述】:

如何将所有子域重定向到 URL 这是场景:

abc.xxx.com 转到 abc.xxx.com/index.php?id=abc www.xxx.com/abc 或 xxx.com/abc 也转到相同的 URL:abc.xxx.com/index.php?id=abc

请记住,网站上没有 /abc 文件夹

并且文件index.php是主域的根文件

我想将 abc 保留在子域中以用于 SEO。

提前致谢。

【问题讨论】:

  • 我试过这个,但它会创建一个无限循环 RewriteCond %{HTTP_HOST} ^(?:www\.)?((?!www).+)\.xxx\.com[NC] RewriteRule !^%1 https://%1.xxx.com/index.php?CN=%1&r=%{REQUEST_URI} [NE,L,R=301]

标签: apache .htaccess url redirect subdomain


【解决方案1】:

我认为你必须首先检查URL是否不包含“index.php?id=”以防止无限循环。

RewriteCond %{REQUEST_URI} !index\.php\?id= [NC]

【讨论】:

  • 谢谢,实际上它适用于 index.php 但我在索引中调用的所有其他文件(如 css)都无法正确调用,因为所有文件都在调用 abc.xxx.com/index.php ?id=abc
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-19
  • 2015-07-17
  • 2015-02-13
  • 2013-08-24
  • 2023-03-27
  • 2017-04-22
  • 2014-09-29
相关资源
最近更新 更多