Im trying to set index.php file in my html folder as localhost:5555
and my second index.php file in html/highlighter folder as localhost:5555/highlighter
with first everything okay, but with second one not, when i go to localhost:5555/highlighter
it prints 404 Not Found
Can you help me?
My folders tree:
nginx │ ├── html │ ├── 50x.html │ ├── highlight │ │ ├── functions.php │ │ ├── icon.png │ │ ├── index.css │ │ ├── index.php │ └── index.php ├── nginx.exe
nginx.conf
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; server { listen 5555; server_name localhost; location / { root html; index index.php; } location /highlighter { root html/highlight; index index.php; } location ~ .php$ { fastcgi_pass 127.0.0.1:9123; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
UPDATE
My mistake was adding 2 roots in location blocks, if you have same error, try move root from location block like this
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 5555; server_name localhost; root "D:\Miscellaneous\nginxSites"; location / { index index.php; } location /highlighter { index index.php; } location ~ .php$ { fastcgi_pass 127.0.0.1:9123; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
Advertisement
Answer
You can try the following approach:
location /highlighter { alias /var/www/html/highlighter/; index index.php index.html; #try_files $uri $uri/ =404; try_files $uri $uri/ /highlighter/index.php; }