2012-09-14 49 views
1

我有一個客戶端域,有數千個正在移動到新域的頁面。 .html的命名約定已經改變了,我知道htaccess可以以某種方式處理它。帶有更復雜重定向的htaccess 301

下面是一個例子:

舊網站:http://oldsite.com/west-virginia/new-cumberland-wv-index.html

新網站:http://newsite.com/west-virginia/computer-support-new-cumberland-wv-index.html

我也有那裏的東西像newcumberland被重命名爲newcumberland

這是幾個問題超出我目前的理解。我會感激一點幫助。謝謝!

回答

0

看起來您可能需要根據具體情況進行此操作,除非您可以找到這些更改的確定模式。重定向自己會是這個樣子:

RedirectMatch 301 ^/([^/]+)/([^/]+)\.html$ /$1/computer-support-$2.html 

第一([^/]+)狀態相匹配,而第二([^/]+)的HTML文件的名稱相匹配。這個重定向只是在html文件前添加一個computer-support-

+0

這是非常有幫助的。謝謝! – coneH34D

0

非常感謝您指點我正確的方向!這是最後的實現:

Options +FollowSymLinks -MultiViews 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^oldsite.com$ [NC] 
RewriteRule ^([^/]+)/(computer-repair-in-)(.+)-index\.html$ http://newsite.com/$1/computer-support-$3-index.html [QSA,R=301]