Learn about Centmin Mod LEMP Stack today
Become a Member

Nginx Rewrite rules for Shortener site

Discussion in 'Other Web Apps usage' started by ndha, Aug 3, 2017.

  1. ndha

    ndha Member

    55
    9
    8
    Sep 28, 2014
    Ratings:
    +23
    Local Time:
    8:26 PM
    Latest
    10
    Hi all,

    i just play with shortener url site using nginx.
    But it only had .htacces rules which is i must make my own nginx rewrite for it..
    Here it is :
    Code:
    ## Admin Panel
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^admin/(.*)?$ admin/index.php?a=$1 [QSA,NC,L]
    
    ## Sitemap ###
    RewriteRule ^sitemap.xml$ sitemap.php
    
    ## Application Handler
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)?$ index.php?a=$1 [QSA,NC,L]
    
    ## Error 404 ##
    ErrorDocument 404 /index.php?a=404
    
    So i use anilcetin site to convert it (i knew it's not 100% accurate),
    here it's nginx rewrite for it :
    Code:
    rewrite ^/admin/(.*)?$ /admin/index.php?a=$1 last;
    rewrite ^/sitemap.xml$ /sitemap.php;
    rewrite ^/(.*)?$ /index.php?a=$1 last;
    error_page 404 /index.php?a=404;
    
    can someone confirm this nginx rewrite is ok ??
    or i must add something on it..
    or @eva2000 can give some lights on it..
    Thanks for any help..
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,850
    6,905
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,396
    Local Time:
    11:26 PM
    Nginx 1.13.x
    MariaDB 5.5
    what is the shortener script name ? have you asked official developers for their official nginx rules or if their official documentation has ones ?
     
  3. ndha

    ndha Member

    55
    9
    8
    Sep 28, 2014
    Ratings:
    +23
    Local Time:
    8:26 PM
    Latest
    10
    it is Premium URL Shortener..
    They only had nginx rewrite for Admin page..
    Other rules must convert again..
    I think their sitemap rule still broken..