簡體   English   中英

使用.htaccess從301重定向中遞歸排除目錄

[英]Exclude a directory recursively from 301 redirect using .htaccess

我剛剛啟動了一個新網站(基於Wix),其地址為http://lifeworks.life 我已將舊站點(WordPress)存檔在http://lifeworkslearningcetner.com/archive ,將所有文件(除了一個.htaccess文件)從http://lifeworkslearningcenter.com的根文件夾中移出,以保持重定向和SEO流程暢通無阻。

我有特定的重定向工作,以及根級別的重定向。 但是現在,URL http://lifeworkslearningcenter.com/archive重定向到https://www.lifeworks.life/archive ,該URL不存在並且以404結尾。

這是我正在使用的.htaccess代碼。 我想要的是能夠正常訪問前端和后端的/ archive文件夾中的WordPress網站。

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/

您的最后一條語句( Redirect ... )沒有條件,因此始終將您重定向到lifeworks.life。 為了從重定向中排除/ archive請求,您可以使用以下內容代替您的Redirect語句:

RewriteCond %{HTTP_HOST} !^lifeworks\.life$
RewriteCond %{REQUEST_URI} !^/archive
RewriteRule ^(.*)$ http://lifeworks.life/$1 [R=301,L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM