SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2004
    Location
    Newport Beach
    Posts
    1,761
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    NGINX Rewrite Condition if Something is at END of URL?

    Alright,

    I have a lot of incoming links that would activate a cookie and then forward onto a particular page. The url typically looks like this:

    http://www.traileraddict.com/trailer...ailer-b/hdplus

    Nowt that returns a 404 error dude to my new url structure, which I'm forcing a rewrite to. The correct link is now:

    http://www.traileraddict.com/50-50/trailer-b

    Here is the rewrite I'm tying to give an idea:

    Code:
    location /trailer/ {
         rewrite ^/?trailer/([-0-9a-zA-Z]+)/([-0-9a-zA-Z]+)$ /$1/$2 permanent;
    }
    
    location /hdplus {
         rewrite ^/?trailer/([-0-9a-zA-Z]+)/([-0-9a-zA-Z]+)/hdplus$ /$1/$2 permanent;
    }
    Obviously that was a long shot, but hopefully shows what I'm trying to do.

    All feedback appreciated!
    Ryan
    Upcoming Movies - Movie News. Updated Daily.
    Movie Trailers - Awesome trailer site. Nuff said.

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    The '/hdplus' is actually a regex depending on what you feed nginx so you should be able to handle it there. See http://nginx.org/en/docs/http/ngx_ht....html#location for some pointers.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •