2012-12-11 71 views
0

我期待設置2周的.htaccess重新寫,但我不知道他們實際上是這樣的:htaccess的端口轉發網址

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

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

只是爲了應付端口-forwarding問題...

以下是我目前正在:

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] 

回答

0

啓用mod_rewrite的,並通過httpd.conf的.htaccess,然後把這個代碼在你.htaccessDOCUMENT_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] 
+0

感謝。我會給你一個鏡頭。假設我想讓這隻適用於cloud.mysite.com,唯一會改變的將是「www」 - >「cloud」?而對我網站的所有其他www訪問都不會受到影響? – RedBullet

+0

是的,只需用'RewriteCond%{HTTP_HOST}^cloud \ .mysite \ .com $ [NC]'替換'RewriteCond%{HTTP_HOST} ^(www \。)?mysite \ .com $ [NC]' – anubhava

+0

嗯..沒有得到它的工作... – RedBullet