Advertisement
kevin25

CodeIgniter NGINX Rewrite Rules

Jul 17th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. server
  2. {
  3. server_name .example.com;
  4.  
  5. access_log /var/log/nginx/example.com.access.log;
  6.  
  7. root /var/www/example.com/html;
  8.  
  9. index index.php index.html index.htm;
  10.  
  11. if ($host ~* ^www\.(.*))
  12. {
  13. set $host_without_www $1;
  14. rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
  15. }
  16.  
  17. if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$)
  18. {
  19. rewrite ^(.*)$ / permanent;
  20. }
  21.  
  22. if ($request_uri ~* index/?$)
  23. {
  24. rewrite ^/(.*)/index/?$ /$1 permanent;
  25. }
  26.  
  27.  
  28. if (!-d $request_filename)
  29. {
  30. rewrite ^/(.+)/$ /$1 permanent;
  31. }
  32.  
  33.  
  34. if ($request_uri ~* ^/system)
  35. {
  36. rewrite ^/(.*)$ /index.php?/$1 last;
  37. break;
  38. }
  39.  
  40.  
  41. if (!-e $request_filename)
  42. {
  43. rewrite ^/(.*)$ /index.php?/$1 last;
  44. break;
  45. }
  46.  
  47. # catch all
  48. error_page 404 /index.php;
  49. # use fastcgi for all php files
  50. location ~ \.php$
  51. {
  52. fastcgi_pass 127.0.0.1:9000;
  53. fastcgi_index index.php;
  54. fastcgi_param SCRIPT_FILENAME /var/www/example.com/html$fastcgi_script_name;
  55. include fastcgi_params;
  56. }
  57.  
  58. # deny access to apache .htaccess files
  59. location ~ /\.ht
  60. {
  61. deny all;
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement