[英]Redirecting folder from one domain to another using .htaccess 301 redirect
I'm trying to figure out a rewrite so as to redirect a directory and all of it's files & subdirectories from one domain to another. 我正在尝试进行重写,以便将目录及其所有文件和子目录从一个域重定向到另一个域。
Here is what I would like to achieve: 这是我想要实现的目标:
olddomain.com/oldfolder/*
to 至
http://newdomain.com/newfolder/*
Currently I am using the following: 目前,我正在使用以下内容:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*) http://newdomain.com/newfolder/$1 [L,R=301]
This works for www.olddomain.com but not also for olddomain.com. 这适用于www.olddomain.com,但不适用于olddomain.com。 What's the best way to achieve this? 实现此目标的最佳方法是什么?
Thanks so much for your help. 非常感谢你的帮助。
Replace your code with this: 用以下代码替换代码:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^oldfolder/(.*)$ http://newdomain.com/newfolder/$1 [L,R=301,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.