【发布时间】:2014-02-14 10:16:42
【问题描述】:
我遇到了一个问题。 我们使用 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 编码不同。在旧站点中,程序中的空间使用 _ 编码,而在我们当前的站点中,它使用 - 编码
我的铁路路线如下:-
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'
所以我被这个困住了。有人可以建议我解决这个问题的方法吗。
还想知道如果它是一个更好的选择,在后端进行更改是否会更好
【问题讨论】:
-
我不明白如何从“Start_world”重定向到“Boston-Legal”,这甚至不在你的规则中。这种重定向可能发生在 Rails 端。你能发布相关的 Rails 路线吗?
-
@Rico 它正在获取最后一点 url 并将我重定向到那里
-
发布您的 Rails 路线...
-
@Rico 抱歉回复晚了。我已经更新了问题。请查看
标签: ruby-on-rails regex redirect nginx amazon-ec2