apache - How use htacces to run index.php in subfolder in nginx? -


i'm new in nginx.

i stack on run website using nginx.

i have try convert htaccess use nginx.conf or default.d/*.conf site still not working.

here files:

--- .htaccess ---  |-- public     |  |     ---  index.php  |     --- .htaccess  |-- application 

first htaccess

rewriteengine on rewriterule ^(.*) public/$1 [l] 

second htaccess same folder index.php

options -multiviews rewriteengine on options -indexes rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l rewriterule ^(.+)$ index.php?url=$1 [qsa,l] 

this nginx.conf after edit:

user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events {     worker_connections 1024; } http {     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                       '$status $body_bytes_sent "$http_referer" '                       '"$http_user_agent" "$http_x_forwarded_for"';     access_log  /var/log/nginx/access.log  main;     sendfile            on;     tcp_nopush          on;     tcp_nodelay         on;     keepalive_timeout   65;     types_hash_max_size 2048;     include             /etc/nginx/mime.types;     default_type        application/octet-stream;     include /etc/nginx/conf.d/*.conf;     server {         listen       80 default_server;         listen       [::]:80 default_server;         server_name  _;         root         /usr/share/nginx/html;         include /etc/nginx/default.d/*.conf;         autoindex off;         location / {         # first htaccess configuration                  rewrite .* /public/index.php last;         }         error_page 404 /404.html;             location = /40x.html {         }         error_page 500 502 503 504 /50x.html;             location = /50x.html {         }     } } 

and default.d/*.conf

index index.php index.html index.htm; # htaccess configuration autoindex off; if(!-e $request_filename){ rewrite^(.+)$ /index.php?url=$1 break; } location ~ \.php$ {     try_files $uri =404;     fastcgi_intercept_errors on;     fastcgi_index  index.php;     include        fastcgi_params;     fastcgi_param  script_filename  $document_root$fastcgi_script_name;     fastcgi_pass   php-fpm; } 

can me run in nginx?

one option set .../public document root, , rewrite uri beginning /public/ /:

root /usr/share/nginx/html/public;  location / {     try_files $uri @index; } location @index {     rewrite ^/(.*)$ /index.php?url=$1 last; } location /public/ {     rewrite ^/public(.*)$ $1 last; } location ~* \.php$ {     try_files $uri =404;     ... } 

however, if prefer use current document root, may suit requirements:

root /usr/share/nginx/html;  location / {     try_files $uri /public$uri @index; } location @index {     rewrite ^/(.*)$ /index.php?url=$1 last; } location ~* \.php$ {     try_files $uri /public$uri =404;     ... } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -