【问题标题】:.htaccess redirect all subdomain request to current subdomain.htaccess 将所有子域请求重定向到当前子域
【发布时间】:2012-11-10 14:55:06
【问题描述】:

我明白了:

-- root           # example.com 
   profile        # example.com/profile

----- subdomain1  # subdomain1.example.com
----- subdomain2  # subdomain2.example.com
----- subdomain3  # subdomain3.example.com

问题是当来自 subdomain1.example.com/profile 或 subdomain1.example.com/about 的请求时,它们总是重定向到 example.com/profile

我希望来自子域的所有请求,例如:subdomain1.example.com/profile 或 subdomain1.example.com/profile 将重定向到当前请求,而不是重定向到根域,例如:example.com/profile

如何使用 .htaccess 制作它?

【问题讨论】:

  • 在任何人回答这个问题之前,您必须提供有关您的设置的更多详细信息。 当前设置是什么?它是如何工作的?这些“子域”是如何配置的?
  • 我没有任何 .htaccess 配置
  • 除了一些 .htaccess 文件之外,服务器配置还有其他一些东西。正如我之前问过的:这些“子域”是如何配置的?
  • 一会儿 arkascha 我会先找出来的。

标签: .htaccess redirect subdomain


【解决方案1】:

您必须将子域的 DocumentRoot 更改为该子域的根。例如,/path/to/subdomain1.example.com 应该是 subdomain1 的 DocumentRoot。这可以在您的 httpd.conf 文件中完成。你有什么样的服务器?

<VirtualHost subdomain1> 
ServerName subdomain1.example.com
ServerAdmin you@subdomain1.example.com
ServerAlias subdomain1.example.com     
DocumentRoot /path/to/subdomain1.example.com  
</VirtualHost> 

【讨论】:

  • 你有运行 apache2 吗?
  • 如果你这样做,我建议在 httpd.conf 中设置虚拟主机
  • ServerAdmin you@subdomain1.example.com ServerAlias subdomain1.example.com DocumentRoot /path/to/subdomain1.example.com ServerName subdomain1.example.com
  • 我已经尝试过了,但我还有其他问题,我仍然专注于它。抱歉迟到了。谢谢
猜你喜欢
  • 2015-12-29
  • 1970-01-01
  • 2015-02-13
  • 2017-04-22
  • 2014-09-29
  • 2019-12-20
  • 2022-09-30
  • 2011-08-27
相关资源
最近更新 更多