除了一个文件,Apache 301redirect

我目前正在回到一个旧的域名,并为SEO目的创buildredirect。 我没有做这么多,所以我一直在学习。

我试图:

  • 有一些页面301直接到新网站上的等同页面(完成)
  • 有一个单一的页面根本不redirect(需要帮助)
  • 将所有其他页面redirect到新主页(完成)

到目前为止我有:

RedirectMatch 301 contactinfo.html http://www.newdomain.com/contact.php RedirectMatch 301 (.).html http://www.newdomain.com/index.php 

我怎样才能禁止单个页面的redirect?

Redirect指令并没有真正的灵活性来做到这一点。 尝试使用mod_rewrite:

 RewriteEngine on # Equivalent to your first RedirectMatch RewriteRule ^contactinfo\.html$ http://www.newdomain.com/contact.php [R=301,L] # Avoids taking any action on this page. RewriteRule ^filetonotredirect\.html$ - [L] # Equivalent to your second RedirectMatch RewriteRule ^.*\.html$ http://www.newdomain.com/index.php [R=301,L]