)
I am trying to configure a website so that it serves its pages from a subfolder.
The website’s root folder is the following.
/home/infcs/server/public/apps/mysite
The website’s root folder contains an .htaccess that points to the following subfolder that contains the actual website files.
/home/infcs/server/public/apps/mysite/public
The .htaccess file’s content is the following.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
</IfModule>
When I try to load the page http://localhost/apps/mysite, I get the error message:
Not Found
The requested URL was not found on this server.
Apache/2.4.52 (Ubuntu) Server at localhost Port 80
My apache sites-available config file /etc/apache2/sites-available/000-default.conf
looks like follows.
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/infcs/server/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I also have this in my apache config file /etc/apache2/apache2.conf
.
<Directory /home/infcs/server/public/apps/mysite>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I have tried changing .htaccess to the following:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/apps/mysite/public/
RewriteRule ^(.*)$ /apps/mysite/public/$1 [L,QSA]
</IfModule>
Now I can see the page but it fails to load the assets e.g. css, js, etc. For example, I see the following in the console:
GET
http://localhost/store/1/default_images/categories_icons/feather.png
[HTTP/1.1 404 Not Found 0ms]
GET
http://localhost/assets/default/js/app.js
[HTTP/1.1 404 Not Found 0ms]
The store folder is this one:
/home/infcs/server/public/apps/mysite/public/store
The assets folder is this one:
/home/infcs/server/public/apps/mysite/public/assets
I do not know much about .htaccess files, so I tried to hack the .htaccess file by looking at another .htaccess file with which I had some luck, but as you can see, it does not work.
Could you please show me how I can solve this?
Many thanks.