.htaccess 将文件夹下的所有页面重定向到新域 [英] .htaccess redirect all pages under a folder to new domain

查看:28
本文介绍了.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>

这篇关于.htaccess 将文件夹下的所有页面重定向到新域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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