Join the community today
Become a Member

convert apache rewrites to nginx rewrites

Discussion in 'Other Web Apps usage' started by Altair, Aug 28, 2020.

  1. Altair

    Altair Member

    Jan 27, 2018
    Local Time:
    1:21 AM
    i have an application that requires rewrite_module for friendly urls.

    I also have an .htaccess file inside the application folders, its content is below:

    <IfModule mod_rewrite.c>
    RewriteEngine Off

    FileETag INode MTime Size

    <ifModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 300 days"

    <IfModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(js|css)$
    mod_gzip_item_include mime ^text/.*

    <IfModule !mod_gzip.c>
    <IfModule mod_deflate.c>
    <FilesMatch "\.(js|css)$">
    SetOutputFilter DEFLATE

    AddType text/plain .php .php3 .php4 .php5 .phtml .pl .py .jsp .asp .shtml .sh .cgi .htm .html

    how do I convert this into nginx syntax i looked at the page nginx configuration examples but couldn't find intel as my application is custom and not common

  2. eva2000

    eva2000 Administrator Staff Member

    May 24, 2014
    Brisbane, Australia
    Local Time:
    8:21 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    All the above is for setting browser cache control/expires headers and gzip compress of static files which you do not need with Centmin Mod Nginx as out of the box nginx vhosts created all have expire headers/cache control set for static files in global server wide include file at /usr/local/nginx/conf/staticfiles.conf as per Centmin Mod Configuration Files - LEMP Nginx web stack for CentOS

    and gzip compression server wide in /usr/local/nginx/conf/nginx.conf
    Code (Text):
            gzip on;
            gzip_vary   on;
            gzip_disable "MSIE [1-6]\.";
            gzip_static on;
            gzip_min_length   1400;
            gzip_buffers      1024 8k;
            gzip_http_version 1.0;
            gzip_comp_level 5;
            gzip_proxied    any;
            gzip_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;