We have a tool that unfortunately has to be set up in a subfolder - so it can't be moved to the root without a lot of effort. Even if it could, we would have unsightly URLs with parameters attached.
The current setup is something like this:
https://example.com/subfolder1/subfolder2/file.php?page=home
Nicer would be:
https://example.com/home/
Now we have the following RewriteRules:
RewriteEngine On
# www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ %{REQUEST_SCHEME}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# add slash to the end
#RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]`
RewriteRule ^home/$ /subfolder1/subfolder2/file.php?page=home¶m1=foo¶m2=bar
RewriteRule ^contact/$ /subfolder1/subfolder2/file.php?page=contact¶m1=foo¶m2=bar
RewriteRule ^appointments/$ /subfolder1/subfolder2/file.php?page=appointments¶m1=foo¶m2=bar
So the URL https://example.com/home/ is currently "working" - at least the content of the page is there, but of course all relatively used elements (images, JS, CSS, ...) now lead to nowhere because e.g. https://example.com/home/images/ or https://example.com/home/js/ don't exist.
We have tried several other rules to tell Apache "show /home/ but take all other files from /subfolder1/subfolder2/". A few times the whole page was not reachable.
Currently these are the last lines in the htaccess:
RewriteCond %{DOCUMENT_ROOT}/subfolder1/subfolder2/%{REQUEST_FILENAME} -f
RewriteRule (.*) %{DOCUMENT_ROOT}/subfolder1/subfolder2/$1 [L]
What is wrong here? How should it be correct? And why? :)