如何重定向一个子文件夹到不同的域?文件夹、重定向、不同

由网友(1切、都變勒)分享简介:我需要一个子文件夹重定向到具有相同的子文件夹名称的另一个领域。I need to redirect a subfolder to another domain with the same subfolder name.例如,我想重定向以下网址For example, I want to redirect the...

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

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]
阅读全文

相关推荐

最新文章