【问题标题】:Creating wildcard subdomain doesn't work创建通配符子域不起作用
【发布时间】:2012-12-23 10:00:44
【问题描述】:

我想为 mysql 数据库中的每个用户创建一个通配符子域。子域有效,但页面加载时没有相关文件(css、js)。

用户页面列表:

website.com/user/index.php

用户页面:

website.com/user/userpage/user.php?username=john

这是我的重写代码:

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.website.com/user/user.php$ 
RewriteCond %{HTTP_HOST} ^(.*?).website.com$ 
RewriteRule (.*)    user.php?username=%1 

我的重写代码有什么问题吗? .谢谢:D

编辑

忘了一件事,这是我的通配符 *.website.com 目录:

public_html/user

谢谢:D

【问题讨论】:

    标签: mod-rewrite subdomain wildcard


    【解决方案1】:

    这行看起来不对:

    RewriteCond %{HTTP_HOST} !^www.website.com/user/user.php$ 
    

    %{HTTP_HOST} 变量仅用于匹配主机名,而不是路径 (/user/user.php);此外,您应该转义点(它们是正则表达式中的保留字符),因此您应该将其更改为:

    RewriteCond %{HTTP_HOST} !^www\.website\.com
    

    您可能对 Apache 文档的 in this page 感兴趣。

    【讨论】:

      猜你喜欢
      • 2015-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2012-11-14
      相关资源
      最近更新 更多