【发布时间】:2012-03-03 16:52:44
【问题描述】:
我有一个 .htaccess 文件,它使用 mod_rewrite 将 URL 从旧网站重定向到新网页等效项。可以在www.eastwood-whelpton.co.uk 上查看新站点(目前仅适用于 HTML5 浏览器)。
到目前为止,我通过编写大量 Redirect Permanent 语句将每个旧页面翻译到新站点中的位置来完成这项工作。
这一直有效,直到我需要为旧网站创建一个子域(我需要保留它)。以前,它只是在文件夹 /old/ 中,但尽管 Robots.txt 不允许,但 Google 仍会抓取它。为了解决这个问题,我把它放在子域“旧”中。
现在的问题是,访问诸如 old.eastwood-whelpton.co.uk/about.htm 之类的页面仍会尝试重定向到新站点上的 old.eastwood-whelpton.co.uk/about/about.php。
这是我的 HTACCESS 文件的 sn-p。我只需要重定向旧的“www”页面,而不是“旧”子域中的旧页面。
RewriteEngine on
RewriteCond %{HTTP_HOST} ^eastwood-whelpton [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
DirectoryIndex index.php
Redirect permanent /index.htm /index.php
Redirect permanent /index.html /index.php
Redirect permanent /yachthire.htm /holidays/sailingholidays.php
Redirect permanent /yachts.htm /about/thefleet.php
Redirect permanent /handover.htm /training/handover.php
Redirect permanent /holiday.htm /holidays/familyholidays.php
【问题讨论】:
标签: .htaccess redirect subdomain