【问题标题】:htaccess mod_rewrite hostnamehtaccess mod_rewrite 主机名
【发布时间】:2012-10-23 00:18:03
【问题描述】:

如果不匹配,我如何将域 url 重写为特定域名..

假设我希望它只匹配 example.com 并且访问者来自服务器 ip (http://127.0.0.1/something/else) 或来自另一个域 (http://domain.com/something/else)

我怎样才能重写域名并保留所有其他参数,只是域名到 example.com(结果应该是:http://example.com/somthing/else

【问题讨论】:

  • http://127.0.0.1/something/else 不是 IP 地址。您是指来自引荐页面/网址吗?
  • @nickhar 你应该选择名字 ni[tpi]ckhar

标签: apache .htaccess mod-rewrite redirect debian


【解决方案1】:

尝试将这些规则添加到文档根目录中的 htaccess 文件中:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-06
    • 2011-01-12
    • 2014-05-18
    • 1970-01-01
    相关资源
    最近更新 更多