1
我將網站從http://lifeworkslearningcenter.com移至http://lifeworks.life。我爲可以正常工作的單個URL設置了七個301重定向,以及一個簡單的301將基本URL重定向到新的基本URL。通配符301重定向使用.htaccess
現在我需要爲其餘的URL,拼寫錯誤等設置一個通配符。現在發生的事情是:7個重定向中未明確覆蓋的任何URL將重定向到新的基本URL,然後添加以前進入尾端的網址,並導致404像這樣:
http://lifeworkslearningcenter.com/incorrect-url
https://www.lifeworks.life/incorrect-url
這裏是我的.htaccess代碼,包括在通配符前三次嘗試重定向聲明:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
RewriteRule ^about-lifeworks$ "https\:\/\/www\.lifeworks\.life\/team\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
RewriteRule ^services$ "https\:\/\/www\.lifeworks\.life\/services\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
RewriteRule ^methodology$ "https\:\/\/www\.lifeworks\.life\/approach\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
RewriteRule ^sign-up$ "https\:\/\/www\.lifeworks\.life\/enroll\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
RewriteRule ^rates-and-policies$ "https\:\/\/www\.lifeworks\.life\/policies\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
RewriteRule ^contact-us$ "https\:\/\/www\.lifeworks\.life\/contact\.html" [R=301,L]
RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
RewriteRule ^blog$ "https\:\/\/www\.lifeworks\.life\/blog\.html" [R=301,L]
Redirect 301/http://lifeworks.life/
# FAILED ATTEMPTS AT WILDCARD REDIRECT
#RewriteCond %{HTTP_HOST} ^lifeworkslearningcenter\.com$ [OR]
#RewriteCond %{HTTP_HOST} ^www\.lifeworkslearningcenter\.com$
#RewriteRule ^$ "https\:\/\/www\.lifeworks\.life\/index\.html" [R=301,L]
#RedirectMatch 301 /(.*) /$1
#RedirectMatch ^/(.*)$ http://lifeworks.life/$1
我想我錯了我的問題,所以我編輯了你的代碼,在lifeworks.life/後刪除了$ 1,並且它完全按照我的需要工作!即將任何隨機URL重定向到新的基本URL。 – Melodist