2016-05-11 42 views
1

http://lifeworkslearningcenter.comからhttp://lifeworks.lifeにウェブサイトを移動しました。私は、基本URLを新しいベースURLにリダイレクトするための単純な301と同様に、正常に動作している個別のURLに対して7つの301リダイレクトを設定しました。.htaccessを使用してワイルドカード301リダイレクト

残りのURL、タイプミスなどでワイルドカードを設定する必要があります。現在、7つのリダイレクトでカバーされていないURLはすべて新しいベースURLにリダイレクトされ、末尾のURLを入力して、このように404のような結果になります。ここでは

http://lifeworkslearningcenter.com/incorrect-url

https://www.lifeworks.life/incorrect-url

は、ワイルドカードで3つの以前の試みは、redirect文を含め、私の.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 

答えて

3

あなたのワイルドカードリダイレクトはこのようになり、他のルールの一番下に置かれます。

RewriteRule ^(.*)$ https://www.lifeworks.life/$1 [R=301,L] 

ファイルが見つかりません(404)に基づいてリダイレクトする必要がある場合は、これらのルールを使用できます。これらをルールの一番下に置きます。

+0

あなたのコードを編集してlifeworks.life/の後に$ 1を取り除いたので、必要なだけ正確に動作します。ランダムURLを新しいベースURLにリダイレクトする。 – Melodist

関連する問題