.htaccess 将文件夹下的所有页面重定向到新域
问题描述:
我在旧域中的特定文件夹下放置了一些文件,如下所示:http://www.olddomain.com/folder1/.
I have some files placed under a particular folder in my old domain like this: http://www.olddomain.com/folder1/.
我想将所有尝试访问此文件夹下文件的请求重定向到新域.例子:http://www.olddomain.com/folder1/page1.html -> http://www.newdomain.com/page1.html
I want to redirect all requests that try to access files under this folder to a new domain. Example: http://www.olddomain.com/folder1/page1.html -> http://www.newdomain.com/page1.html
如何使用 .htaccess 完成此操作?
How do I accomplish this using .htaccess?
答
试一试.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^folder1(.*)$ http://www.newdomain.com/$1 [L,R=301]
</IfModule>