nginx -AmazonEc2服务器中的URL重定向问题

时间:2014-02-14 10:16:42

标签: ruby-on-rails regex redirect nginx amazon-ec2

我遇到了问题。 我们使用angularJs和ruby on rails为我们的网站创建了一个新网站。我使用amazon EC2进行托管。我分别使用thin和nginx作为网络服务器和应用服务器。

我在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编码对于两者都不同。在旧网站中,程序中的空间使用_编码,而在我们当前的网站中,它使用- <进行编码/ p>

我的铁路路线如下: -

  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'

所以我坚持这个。有人可以建议我解决这个问题。

如果这是一个更好的选择,还想知道在后端进行更改是否更好

1 个答案:

答案 0 :(得分:0)

你的问题令人困惑。您是要登陆abc.com还是apps.abc.com?在下面的正则表达式中,它转发到abc.com

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

从上方将ht tp替换为http