重定向文件夹从一个领域到另一个使用的.htaccess 301重定向 [英] Redirecting folder from one domain to another using .htaccess 301 redirect

查看:201
本文介绍了重定向文件夹从一个领域到另一个使用的.htaccess 301重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一个重写,以重定向目录和它的所有文件和放大器;子目录从一个域到另一个。

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.

下面是我想实现:

olddomain.com/oldfolder / *

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]

这适用于www.olddomain.com但也为olddomain.com。什么是实现这一目标?
的最佳途径 非常感谢您的帮助。

This works for www.olddomain.com but not also for olddomain.com. What's the best way to achieve this?
Thanks so much for your help.

推荐答案

替换您的code这一点:

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]

这篇关于重定向文件夹从一个领域到另一个使用的.htaccess 301重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆