I have the following files on my web server:
/var/www/html/--+ | +-misc--+ | | | +-misc1--+ | | | | | +-index.html | | | +-misc2--+ | | | | | +-index.php | | | +-misc3.php | +-wordpress--+ | +-index.php I have Nginx set up such that http://example.com/ goes to my Wordpress install. On my previous (Apache) setup I was able to easily create aliases to point to the items in misc but I'm unsure how to do this in Nginx.
index index.php index.html; root /var/www/html/wordpress; location ~ [^/]\.php(/|$) { limit_except GET POST {} fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_buffer_size 16k; fastcgi_buffers 16 16k; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SERVER_NAME $host; fastcgi_param HTTP_PROXY ""; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location ~* \.(?:css|js|jpg|jpeg|gif|png|mp4)$ { expires 1M; access_log off; add_header Cache-Control "public"; } location / { try_files $uri $uri/ /index.php; limit_except GET {} } What I'd like is:
- http://example.com/ loads /var/www/html/wordpress/index.php
- http://example.com/misc1 loads /var/www/html/misc/misc1/index.html
- http://example.com/misc2 loads /var/www/html/misc/misc2/index.php
- http://example.com/misc3.php loads /var/www/html/misc/misc3.php
What I've tried:
# http://example.com/misc1 shows index.html but anything else in the folder is 404 location /misc1 { alias /var/www/html/misc/misc1; } # http://example.com/misc1 gives 403, http://example.com/misc1/index.html gives 404 location /misc1/ { alias /var/www/html/misc/misc1; } # shows Wordpress 404 page location /misc1/* { alias /var/www/html/misc/misc1; } # gives 403 error location ~ /misc1 { alias /var/www/html/misc/misc1; } Nothing I've tried has had any effect on PHP, it does not work.