Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx url rewrite #25

Closed
smpcasgit opened this issue Aug 7, 2018 · 1 comment
Closed

nginx url rewrite #25

smpcasgit opened this issue Aug 7, 2018 · 1 comment

Comments

@smpcasgit
Copy link

nginx rewrite not working!
how to nginx server block rewrite?

@VicDeo
Copy link
Contributor

VicDeo commented Aug 9, 2018

Write a nginx config on your own ;)

TL;DR
Disclaimer: I don't use it any more, but it worked for 1.something, feel free to adapt for newer versions

  location / {
       try_files $uri $uri/ @handler;
    }
    
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
       expires 1d;
       gzip_static on;
       etag on;
       access_log off;
    }

    location ~ \.(sdb|md|html|txt)$ {
        deny all;
    }

    location ~ /inc/data.*$ {
        deny all;
    }
    
    location  /admin {
        try_files $uri $uri/ /admin/index.php?$args;
    }
    
    location @handler {
        if (!-e $request_filename) { rewrite / /index.php last; }
        rewrite ^(.*.php)/ $1 last;
    }
    
    location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
        try_files $script_name index.php =404;
        fastcgi_index index.php;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param   SERVER_NAME $host;
        fastcgi_param  PATH_INFO          $path_info;
        fastcgi_read_timeout 180s;        
    }

@klocus klocus closed this as completed Sep 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants