nginx: add new alias

#changes in /etc/nginx/sites-avaliables/default server { server_name example.com; root /path/to/root; location / { # blah blah } location /demo { alias /path/to/root/production/folder/here; } }
Add alias into

2 Responses

#########Help with this Alias not working

#include /etc/nginx/conf.d/*.conf;
server {

listen 80;
listen 443 ssl;
server_name wall1.bhaskar.com;
ssl_certificate /etc/nginx/ssl/bundle.crt;
ssl_certificate_key /etc/nginx/ssl/bhaskar_com.key;
# include hhvm.conf;
root /disk4/wall1.bhaskar.com/public_html;
index index.html index.php;
access_log /var/log/nginx/wall1-access.log;
error_log /var/log/nginx/wall1-error.log;
if (!-e $request_filename){
# rewrite ^(.*)$ /index.php break;
rewrite ^/assets/js/v([0-9]+)/(.+)$ /assets/js/$2 last;
rewrite ^/images/thumbs(.*)$ /disk3/wallimages/thumbs/index.php?thumb=thumbs$1 last;
rewrite ^/images/testthumbs(.*)$ /disk3/wallimages/thumbs/demo.php?thumb=thumbs$1 last;
rewrite ^/(.*)$ /index.php/$1 last;


}
location /disk4/wall1.bhaskar.com/public_html {
try_files \$uri \$uri/ /index.php?\$query_string;
}


location /images {
alias /disk3/wallimages/images;
index index.php;

}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /disk4/wall1.bhaskar.com/public_html$fastcgi_script_name;
index index.php;
fastcgi_index index.php;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# Deny .htaccess file access
location ~ /\.ht {
deny all;
}
}
try this:

location ^~ /images {
alias /disk3/wallimages/images;
try_files $uri $uri/ =404;
}

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.