使用.htaccess

时间:2016-05-12 06:27:10

标签: wordpress apache .htaccess redirect

我刚刚在地址http://lifeworks.life推出了一个新网站(建于Wix上)。我已经在http://lifeworkslearningcetner.com/archive存档旧网站(WordPress),从http://lifeworkslearningcenter.com的根文件夹移动除.htaccess文件之外的所有文件,以保持重定向和SEO汁流。

我有特定的重定向工作,以及根级重定向。但现在,网址http://lifeworkslearningcenter.com/archive会重定向到https://www.lifeworks.life/archive,该版本不存在,并以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/

1 个答案:

答案 0 :(得分:0)

您的上一个声明(Redirect ...)没有条件,因此始终会将您重定向到lifeworks.life。 要从重定向中排除 / archive 请求,您可以使用以下内容而不是Redirect语句:

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