htaccess端口转发URL

时间:2012-12-11 15:42:32

标签: regex apache .htaccess mod-rewrite portforwarding

我希望设置2 .htaccess重写,但不确定它们实际上是什么样的:

http://www.mysite.com -> http://www.myothersite.com:880

https://www.mysite.com -> https://www.myothersite.com:4443

只是处理端口转发问题......

以下是我目前正在尝试的内容:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^cloud\.mysite\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ http://mysite.no-ip.org:880%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^cloud\.mysite\.com$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^ https://mysite.no-ip.org:4443%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^mysite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/joomla" [R=301,L]

1 个答案:

答案 0 :(得分:0)

通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在.htaccess目录下的DOCUMENT_ROOT中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ http://www.myothersite.com:880%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^ https://www.myothersite.com:4443%{REQUEST_URI} [R=301,L]
相关问题