Website folder structure / url rewriting

I’m currently using a nohost.me domain name, and I’m having some trouble getting my site served with this folder structure:

$ tree
.
├── assets
│   ├── css
│   ├── img
│   └── js
├── en
│   ├── about
│   │   └── index.html
│   ├── index.html
│   └── trends
│       └── index.html
└── es
    ├── about
    │   └── index.html
    ├── index.html
    └── trends
        └── index.html

Any suggestions how I can serve a site with that structure? I installed my_webapp, and if I put an index.html in /var/www/my_webapp/ it gets served fine by visiting foo.nohost.me/site, but with the above folder structure in the same location I get a 403 Forbidden page. I tried doing some url rewriting in some of the config files in /etc/nginx/conf.d/, like:

location / {
    rewrite ^/$ /en break;
}

but it wasn’t working out.

Hello. Did you check the rights on your files and folders ?

Thanks for your reply.

/var/www# ls -la
drwxr-xr-x  4 root root     4096 Jan 31 01:32 .
drwxr-xr-x 12 root root     4096 Sep 16 11:12 ..
drwxrwxr-x  5 user www-data 4096 Feb 11 13:29 my_webapp
drwxr-xr-x  3 root root     4096 Sep 16 11:12 yunohost

/var/www/my_webapp# ls -la
drwxrwxr-x 5 user www-data 4096 Feb 11 13:29 .
drwxr-xr-x 4 root root     4096 Jan 31 01:32 ..
drwxr-xr-x 5 user    19895 4096 Feb 11 13:26 assets
drwxr-xr-x 2 user    19895 4096 Feb 11 13:26 en
drwxr-xr-x 2 user    19895 4096 Feb 11 13:29 es

Looks like the files under /var/www/my_webapp have their group as 19895 which is the regular user’s GID:

# id -g www-data
33
# id -g user
19895

Are they supposed to belong to the www-data group?

I didn’t notice this before, but the pages are accessable by opening foo.nohost.me/site/en in a web browser, should I be trying to do some kind of url redirect from foo.nohost.me/site to there?

I think the rights are fine but you should try to change your nginx config in /etc/nginx/conf.d/domain.tld.d/my_webapp.conf according to your structure, especially the index parameter (something like index /en/index.html) or alias directory. Moreover if your site is just static html files all the fastcgi configuration is useless.

Hmm, by making alias /var/www/my_webapp/en/; the webpage gets served, but to the browser the /en is hidden, /es returns 404 Not Found, and the links to /assets are broken.

By doing index /en/index.php /en/index.html /en/index.htm; I get sent to a yunohost login page at: https://foo.nohost.me/yunohost/sso/?r=<base64 encoded url to https://foo.nohost.me/en/index.html>, which I can’t seem to actually login to… it gives a 500 Internal Server Error when I try.

Hi,
A possibility is to leave the conf file “as is” and simply put a php redirection in /var/www/my_webapp
The php redirection is a file index.php with:

<?php
header("Location: http://foo.nohost.me/site/en/");
exit;
?>

Ah thank you, that is working :slight_smile: