Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Changing Root Directory

$
0
0
Hello everyone,

I built a WordPress site working fine. The address is "http://mydomain.com" for example.

Then I would like to indicate "http://mydomain.com/data/" to /home/data/index.html .
So I modified the following /etc/nginx/default.d/locations.conf file.

$ cat locations.conf
location ~* /wp-config.php {
deny all;
}

# Beginning of Insertion this time
location /data/ {
root /home/data;
index index.html;
}
# End of Insertion this time

location / {
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
$

After restarting nginx I accessed "http://mydomain.com/data/".
Then browser showed /usr/share/nginx/html/404.html file.

The permission and owner of /home/data/index.html is the following.

$ LANG=en ls -la /home/data
total 4
drwxrwxrwx 2 nginx nginx 24 Jan 5 11:52 .
drwxr-xr-x. 5 root root 42 Jan 5 11:37 ..
-rw-rw-r-- 1 nginx nginx 142 Dec 15 18:30 index.html
$

How should I write the configuration file?
Please help me.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>