.htaccess将文件夹下的所有页面重定向到新域

时间:2021-10-21 11:04:02

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/。

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

我想将尝试访问此文件夹下的文件的所有请求重定向到新域。示例:http://www.olddomain.com/folder1/page1.html - > http://www.newdomain.com/page1.html

How do I accomplish this using .htaccess?

我如何使用.htaccess完成此操作?

1 个解决方案

#1


27  

Give this a shot.

试一试。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^folder1(.*)$ http://www.newdomain.com/$1 [L,R=301]

</IfModule>

#1


27  

Give this a shot.

试一试。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^folder1(.*)$ http://www.newdomain.com/$1 [L,R=301]

</IfModule>