【问题标题】:Mod_rewrite matching both subdomain and query stringMod_rewrite 匹配子域和查询字符串
【发布时间】:2011-01-19 21:00:38
【问题描述】:

我目前正在将 domain.com/a/123/abc 改写为 page.php?this=123&that=abc

RewriteRule ^a/([^/]+)/([^/]+)/?$ page.php?this=$1&that=$2 [L]

此外,我现在想将 a.domain.com/123/abc 修改为 page.php?this=123&that=abc

所以a.domain.com/123/abcdomain.com/a/123/abc 都会重定向到page.php?this=123&that=abc

我的问题是匹配子域和查询字符串。这是我一直在做的,但仍然没有正确重写。

RewriteCond %{HTTP_HOST} ^a\.domain\.com/ [NC]
RewriteCond %{QUERY_STRING} /([^/]+)/([^/]+)/?$ [NC]
RewriteRule ^(.*) /a/$1/$2 [L]

请注意,已设置通配符域 (*.domain.com)。只是 htaccess mod_rewriting 失败了。

【问题讨论】:

    标签: php .htaccess apache


    【解决方案1】:

    RewriteCond 后面的/ 吗?

    RewriteCond %{HTTP_HOST} ^a\.domain\.com/
    

    应该是

    RewriteCond %{HTTP_HOST} ^a\.domain\.com
    

    【讨论】:

    • 不,但删除它没有任何区别
    猜你喜欢
    • 2014-06-20
    • 1970-01-01
    • 2011-01-16
    • 2011-03-11
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 2014-01-08
    相关资源
    最近更新 更多