我试图找出一个重写,以重定向目录和它的所有文件和放大器;子目录从一个域到另一个。
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]
上一篇:如何从旧的PHP脚本重定向到一个新的PHP脚本使用mod_rewrite脚本、重定向、PHP、mod_rewrite
下一篇:在.htaccess和preserve查询字符串替换URL的一部分字符串、htaccess、preserve、URL