【问题标题】:redirect username to subdomain将用户名重定向到子域
【发布时间】:2011-04-21 12:29:12
【问题描述】:

我需要一个可以做到的脚本

blogname.domain.com = > http://www.domain.com/blogname/

我认为 .htaccess 文件可能,但我不知道,所以请帮助我

非常感谢

【问题讨论】:

  • 您使用的是什么 CMS? WordPress?
  • 查找 mod_rewrite。匹配主机名,提取博客名,重写为其他格式。

标签: php .htaccess subdomain wildcard-subdomain


【解决方案1】:

在 .htaccess 中,您可以执行以下操作

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^[^.]+\.domain\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^([^.]+)\.domain\.com(.*)    http://www.domain.com/$1$2

这将重写http://username.domain.com/anypath
内部给http://www.domain.com/username/anypath

【讨论】:

    猜你喜欢
    • 2016-08-24
    • 1970-01-01
    • 1970-01-01
    • 2016-01-30
    • 1970-01-01
    • 2014-10-10
    • 2012-07-22
    • 2021-05-29
    • 2011-08-27
    相关资源
    最近更新 更多