【问题标题】:htaccess rewrite condtion only for specific domain not sub folderhtaccess 仅针对特定域而不是子文件夹重写条件
【发布时间】:2014-08-14 16:19:31
【问题描述】:

我当前的代码是这样的

Redirect 301 /index.html http://example.com/
Redirect 301 /about.html http://example.com/
Redirect 301 /contact.html http://example.com/contact.php

但是,这会影响指向该站点子文件夹的另一个域。

有没有办法说 if(DOMAIN != 'example2.com'){...}

我也使用类似这样的其他 RewriteRule 函数

RewriteRule ^events/?$ events_page.php [L]

这也是为了删除 www

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

【问题讨论】:

    标签: apache


    【解决方案1】:

    想不出特别优雅的方式,但以下应该可以完成工作:

    RewriteCond %{HTTP_HOST} !^example2\.com
    RewriteRule /(index|about)\.hmtl http://example.com/ [R=301,L]
    
    
    RewriteCond %{HTTP_HOST} !^example2\.com
    RewriteRule /contact\.hmtl http://example.com/contact.php [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2011-08-27
      • 2017-12-24
      • 2013-12-31
      • 2019-12-21
      • 1970-01-01
      • 2013-12-03
      • 2013-09-23
      • 2011-10-14
      • 2017-09-08
      相关资源
      最近更新 更多