【问题标题】:Apache mod_rewrite redirectApache mod_rewrite 重定向
【发布时间】:2012-03-09 21:07:39
【问题描述】:

我刚刚创建了一个子域 info.domain.com,我想要将登录我网站的每个用户与一个子域关联起来,例如 jose.domain.com、juan.domain.com 等... 的代码是什么。 htaccess?

【问题讨论】:

    标签: apache mod-rewrite


    【解决方案1】:

    您想使用通配符子域。以下应将除 www 以外的所有内容传递给 index.php 文件,其中 GET 参数用户等于用户名。

    RewriteCond %{HTTP_HOST} !www.example.com [NC]
    RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).example.com [NC]
    Rewriterule ^(.*)$ /index.php?user=$1 [NC,L]
    

    【讨论】:

    • 这给了我内部服务器错误
    猜你喜欢
    • 2019-02-02
    • 2013-05-26
    • 2012-11-12
    • 2018-01-14
    • 2014-10-06
    • 2023-03-18
    • 1970-01-01
    • 2011-08-14
    • 2014-07-04
    相关资源
    最近更新 更多