title: Url redirection issue in nginx -AmazonEc2 server
body: <p>I am getting an issue.
  We have created a new website for our site using angularJs and ruby on rails.I am using amazon EC2 for hosting purpose.I have used thin and nginx as webserver and application server respectively.</p>
  
  <p>I have made changes in the nginx.conf file and have written redirection rules.However I am having an issue while implementing the same.</p>
  
  <p>While going to TV guide from a website,the url it is showing is :-</p>
  
  <pre><code>http://www.abc.com/WhatsOnTV/Star_world/Boston-legal.aspx?Time=140220141300
  </code></pre>
  
  <p>It is redirecting me to:-</p>
  
  <pre><code>http://apps.abc.com/WhatsOnTV/Program/Boston_legal.aspx
  </code></pre>
  
  <p>Whereas it should have landed on:-</p>
  
  <pre><code> abc.com/program/Boston-Legal 
  </code></pre>
  
  <p>This is happening because of the the config file in which I have written the rule(which cannot be removed as we require it ):- </p>
  
  <pre><code>rewrite (?i)^/WhatsOnTV(.*) http://apps.abc.com/WhatsOnTV$1 permanent; 
  </code></pre>
  
  <p>Also another issue I am facing is that the url encoding is different for both.In the old site the space in programs was encoded with <code>_</code> and in our current site it is encoded with <code>-</code></p>
  
  <p>My rails routes are the following:-</p>
  
  <pre><code>  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"             =&gt; "channel#index"
    get "channels/details"     =&gt; "channel#details"
    get "home"                 =&gt; "home#index"
    get "languages"            =&gt; "languages#index"
    get "genre"                =&gt; "genre#index"
    get "languages/accounts"   =&gt; "languages#accounts"
    get "programme"            =&gt; "programme#index"
    get "programme/info"       =&gt; "programme#info"
    get "search"               =&gt; "search#index"
    get "movies"               =&gt; "movies#index"
    get "videos"               =&gt; "videos#index"
    get "apps"                 =&gt; "apps#index"
    get "tv-guide"             =&gt; "tv-guide#index"
    get "tv-guide/calendar"    =&gt; "tv-guide#calendar"
    get "tv-guide/tvoperator"  =&gt; "tv-guide#tvoperator"
    get "tv-guide/accountstvoperator" =&gt; "tv-guide#accountstvoperator"
    get "pop-up/show"          =&gt; "pop-up#show"
    get "pop-up/genre"         =&gt; "pop-up#genre"
    get "pop-up/showChannelGenre" =&gt; "pop-up#showChannelGenre"
    get "pop-up/showRating"    =&gt; "pop-up#rating"
    get "pop-up/reminder"      =&gt; "pop-up#reminder"
    get "user/signin"          =&gt; "user#signin"
    get "user/signup"          =&gt; "user#signup"
    get "user/forgot-password" =&gt; "user#forgotPassword"
    get "user/popup_login"     =&gt; "user#popup_login"
    get "user/beforeaction"    =&gt; "user#beforeaction"
    get "user/watchlist"       =&gt; "user#watchlist"
    get "user/reminders"       =&gt; "user#reminders"
    get "verify/index"         =&gt; "verify#index"
    get "watchlist"            =&gt; "watchlist#index"
    get "watchlistinfo"        =&gt; "watchlist#info"
    get "movies/popover"       =&gt; "movies#popover"
    get "watchlist/calendar"   =&gt; "watchlist#calendar"
    get "ip"                   =&gt; "ip#index"
    get "actor/profile"        =&gt; "actor#profile"
    get "productions"          =&gt; "productions#index"
    get "crawler/crawlhome"    =&gt; 'crawler#crawlhome'
    get "crawler/crawlprogram" =&gt; 'crawler#crawlprogram'
    get "crawler/crawlchannel" =&gt; 'crawler#crawlchannel'
    get "crawler/crawlchannels" =&gt; 'crawler#crawlchannels'
    get "crawler/crawlactor"   =&gt; 'crawler#crawlactor'
    get "crawler/crawltvlistings"   =&gt; 'crawler#crawltvlistings'
    get "crawler/crawlmovies" =&gt; 'crawler#crawlmovies'
    get "crawler/crawlvideos" =&gt; 'crawler#crawlvideos'
    get "crawler/crawlmobileapps" =&gt; 'crawler#crawlmobileapps'
  
    get "videos/sitemap"     =&gt; 'videos#sitemap'
  </code></pre>
  
  <p>So I am stuck with this.Can someone please suggest me some way to tackle this.</p>
  
  <p>Also want to know if it would be better just to make changes in the backend if it's a better option</p>