htaccess to Nginx

Discussion in 'Nginx' started by malo, Sep 8, 2010.

  1. #1
    Hi, can anybody help be to convert this htaccess file to a nginx rewrite.
    Thanks
    Malo

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domain.com$
    RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]
    RewriteRule ^([_A-Za-z0-9-]+)/([0-9]+)/([_A-Za-z0-9-]+)/?$ saisons.php?&numero=$2
    RewriteRule ^([_A-Za-z0-9-]+)/([0-9]+)/([_A-Za-z0-9-]+)/([0-9]+).html saisons.php?&numero=$2&page=$4
    RewriteRule ^film/([_A-Za-z0-9-]+)/([0-9]+)/([_A-Za-z0-9-]+) regarder.php?eid=$2
    RewriteRule ^([_A-Za-z0-9-]+).html index.php?$1.php [L]
    </IfModule>

    Thanks in advance
     
    malo, Sep 8, 2010 IP
  2. st1905

    st1905 Well-Known Member

    Messages:
    573
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Here it is.

    if ($host = 'domain.com' ) {
            rewrite  ^/(.*)$  http://www.domain.com/$1  permanent;
    	      }
    
    Code (markup):
    The above goes to server section.

    rewrite ^/([_A-Za-z0-9-]+)/([0-9]+)/([_A-Za-z0-9-]+)/?$ /saisons.php?&numero=$2;
    	rewrite ^/([_A-Za-z0-9-]+)/([0-9]+)/([_A-Za-z0-9-]+)/([0-9]+).html /saisons.php?&numero=$2&page=$4;
    	rewrite ^/film/([_A-Za-z0-9-]+)/([0-9]+)/([_A-Za-z0-9-]+) /regarder.php?eid=$2;
    	rewrite ^/([_A-Za-z0-9-]+).html /index.php?$1.php last;
    Code (markup):
    The above goes to location section.
     
    Last edited: Sep 10, 2010
    st1905, Sep 10, 2010 IP