Learn about Centmin Mod LEMP Stack today
Register Now

Nginx Rewrite rules for Shortener site

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

  1. ndha

    ndha Member

    71
    9
    8
    Sep 28, 2014
    Ratings:
    +27
    Local Time:
    5:24 AM
    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

    37,305
    8,152
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,548
    Local Time:
    8:24 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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

    71
    9
    8
    Sep 28, 2014
    Ratings:
    +27
    Local Time:
    5:24 AM
    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..
     
..