2015-01-06 51 views
0

在我的apache2.conf文件中,我給出了代碼,但我想重寫url。即,當我經過的網址,它應該刪除的端口號8080 &應該重定向到http://myapp.example.comApache重寫url rails服務器

<VirtualHost *:80> 
     ServerName example.com 
     DocumentRoot /home/myapp 
     <Directory /home/myapp/public> 
     AllowOverride all 
     Options -MultiViews 
     RewriteEngine on 
     RewriteCond %{HTTP_HOST} ^myapp.example\.com$ [NC] 
      RewriteRule ^(.*)$ http://myapp.example.com:8080/$1 [R=301] 
      Allow from all 
     </directory> 
    </VirtualHost> 

任何人都可以點我在正確的方向是什麼,我在這裏失蹤?

在此先感謝。

回答

0

能否請您試試這個

<VirtualHost *:80> 
      ServerName example.com 
      DocumentRoot /home/myapp 
      <Directory /home/myapp/public> 
      AllowOverride all 
      Options -MultiViews 
      RewriteEngine on 
      RewriteCond %{HTTP_HOST} ^myapp.example\.com:8080$ [NC] 
       RewriteRule ^(.*)$ http://myapp.example.com/$1 [R=301] 
       Allow from all 
      </directory> 
     </VirtualHost> 
+0

不能使用此代碼,它給出錯誤[Apache/2.4.7(Ubuntu)服務器myapp.example .com 80端口] – railslearner

+0

這個怎麼樣,用^(myapp.example.com)代替^ myapp.example \ .com:8080:8080 $ –

+0

沒有它給同樣的錯誤:( – railslearner

0

我已經解決了這個問題,只是通過改變這個

RewriteCond %{HTTP_HOST} ^myapp\.example\.com$ [NC] 
RewriteRule ^(.*)$ http://myapp.example.com:8080/$1 [R=301] 

我希望這將有助於

+0

好。這將有所幫助。 –