I bought a VPS running Ubuntu 20.04. I am fairly new to all the hosting and Linux stuff and I’m struggling on setting up the following situation or if this is even possible:
I have my /var/www folder which has many subfolders. Each holds a website.
I want, if someone access my domain (e.g. mydomain.com) he should see the folder /var/www/codeiginiter4/. But when someone excess mydomain.com/foldername he should see the content of the /var/www/foldername/.
What makes it a little more tricky:
CodeIgniter uses the following .htaccess for apache:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
This applies the mydomain.com/foo to mydomain.com/index.php/foo for the CodeIgniter SEO friendly URL routing. For nginx they provide
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
I got it working with
location ~* ^/(assets|files|robots\.txt) { }
But I have the issue that whatever you add after mydomain.com/ will route to my CodeIgniter folder instead of other websites in other folders.
From my understanding try_files $uri $uri/ /index.php$is_args$args;
will check $uri
(a file), then a folder $uri/
first, so it should serve a folder if there is one, but I always end in my CodeIgniter page.