如何重定向一个子文件夹到不同的域? [英] How to redirect a subfolder to a different domain?

查看:314
本文介绍了如何重定向一个子文件夹到不同的域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个子文件夹重定向到具有相同的子文件夹名称的另一个领域。

I need to redirect a subfolder to another domain with the same subfolder name.

例如,我想重定向以下网址

For example, I want to redirect the following url

www.domain.com/photo

...到另一个域名,但相同的子文件夹

...to another domain but same subfolder

www.domain2.net/photo

...在的.htaccess 使用的mod_rewrite

推荐答案

尝试在你的.htaccess文件这些行:

Try these lines in your .htaccess file:

Options +FollowSymlinks -MultiViews
RewriteEngine on

# for HTTP
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain2.net/$1 [R=301,L]

# for HTTPS
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain2.net/$1 [R=301,L]

这篇关于如何重定向一个子文件夹到不同的域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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