2014-02-14 122 views
0

我遇到問題。 我們使用angularJs和ruby on rails爲我們的網站創建了一個新網站。我使用amazon EC2作爲託管目的。我分別使用thin和nginx作爲web服務器和應用程序服務器。nginx中的Url重定向問題-AmazonEc2服務器

我已經對nginx.conf文件進行了更改,並且寫了重定向規則。但是,在實現相同的操作時遇到問題。

雖然從網站去電視指南,它顯示的網址是: -

http://www.abc.com/WhatsOnTV/Star_world/Boston-legal.aspx?Time=140220141300 

它重定向我: -

http://apps.abc.com/WhatsOnTV/Program/Boston_legal.aspx 

雖然它應該已經登陸: -

abc.com/program/Boston-Legal 

發生這種情況是因爲我寫了規則的配置文件(無法刪除因爲我們需要它): -

rewrite (?i)^/WhatsOnTV(.*) http://apps.abc.com/WhatsOnTV$1 permanent; 

而且我現在面臨的另一個問題是,URL編碼both.In是不同的舊網站,節目中的空間被編碼爲_,並在我們目前的網站被編碼與-

我的軌道路線如下: -

WoiWeb::Application.routes.draw do 
    get "appi/index" 
    get "appi/reco" 
    get "appi/auto" 
    get "appi/tsm" 
    get "appi/user" 


    get "myaccount/index" 
    post "myaccount/create" 

    get "socialfeed/index" 

    get "myprofile/index" 

    get "discussion/home" 

    get "discussion/newdiscussion" 

    get "sitemap/index" 

    get "privacy/index" 

    get "tnc/index" 

    get "corporate/index" 

    get "contact/index" 

    get "about/index" 

    get "apps/index" 

    get "videos/index" 

    get "movies/index" 

    get "pop_up/show" 
    get "watchlistsocial/index" 
    get "favourites/index" 
    get "reminders/index" 

    get "channels"    => "channel#index" 
    get "channels/details"  => "channel#details" 
    get "home"     => "home#index" 
    get "languages"   => "languages#index" 
    get "genre"    => "genre#index" 
    get "languages/accounts" => "languages#accounts" 
    get "programme"   => "programme#index" 
    get "programme/info"  => "programme#info" 
    get "search"    => "search#index" 
    get "movies"    => "movies#index" 
    get "videos"    => "videos#index" 
    get "apps"     => "apps#index" 
    get "tv-guide"    => "tv-guide#index" 
    get "tv-guide/calendar" => "tv-guide#calendar" 
    get "tv-guide/tvoperator" => "tv-guide#tvoperator" 
    get "tv-guide/accountstvoperator" => "tv-guide#accountstvoperator" 
    get "pop-up/show"   => "pop-up#show" 
    get "pop-up/genre"   => "pop-up#genre" 
    get "pop-up/showChannelGenre" => "pop-up#showChannelGenre" 
    get "pop-up/showRating" => "pop-up#rating" 
    get "pop-up/reminder"  => "pop-up#reminder" 
    get "user/signin"   => "user#signin" 
    get "user/signup"   => "user#signup" 
    get "user/forgot-password" => "user#forgotPassword" 
    get "user/popup_login"  => "user#popup_login" 
    get "user/beforeaction" => "user#beforeaction" 
    get "user/watchlist"  => "user#watchlist" 
    get "user/reminders"  => "user#reminders" 
    get "verify/index"   => "verify#index" 
    get "watchlist"   => "watchlist#index" 
    get "watchlistinfo"  => "watchlist#info" 
    get "movies/popover"  => "movies#popover" 
    get "watchlist/calendar" => "watchlist#calendar" 
    get "ip"     => "ip#index" 
    get "actor/profile"  => "actor#profile" 
    get "productions"   => "productions#index" 
    get "crawler/crawlhome" => 'crawler#crawlhome' 
    get "crawler/crawlprogram" => 'crawler#crawlprogram' 
    get "crawler/crawlchannel" => 'crawler#crawlchannel' 
    get "crawler/crawlchannels" => 'crawler#crawlchannels' 
    get "crawler/crawlactor" => 'crawler#crawlactor' 
    get "crawler/crawltvlistings" => 'crawler#crawltvlistings' 
    get "crawler/crawlmovies" => 'crawler#crawlmovies' 
    get "crawler/crawlvideos" => 'crawler#crawlvideos' 
    get "crawler/crawlmobileapps" => 'crawler#crawlmobileapps' 

    get "videos/sitemap"  => 'videos#sitemap' 

所以我堅持this.Can有人請建議我一些方法來解決這個。

也想知道它是否會更好只是爲了在後端的變化,如果它是一個更好的選擇

+0

我不明白「Start_world」是如何重定向到「Boston-Legal」的,即使在你的規則中也沒有。這種重定向可能發生在Rails方面。你能發佈相關的Rails路線嗎? – Rico

+0

@Rico它採取了網址的最後一位,並重定向我那裏 –

+0

張貼您的Rails路線... – Rico

回答

0

你的問題是混亂的。您是否登陸abc.comapps.abc.com?另外,在以下的正則表達式其轉發到abc.com

rewrite (?i)^/.*/(.*?)\.aspx\? ht tp://abc.com/program/$1 permanent; 

從上方更換ht tp作爲http

+0

我登陸到應用程序。 abc.com而不是abc.com..Will以上幫助我?? –

+0

我不確定,可能你可以通過用'[R = 301,L]' –

+0

替換'permanent'來做到這一點,我的意思是你沒有指定這個代碼 永久 –