As an example, I am accessing project foo
at https://localhost/projects/foo/dev/
.
I'd like to rewrite the URL so that https://localhost/projects/foo/
points to projects/foo/dev/
in my DocumentRoot folder
This should not be an HTTP 3xx redirect. Furthermore dev1
, dev2
, and so on should not be accessible (unless there are directories inside of dev
with those names but that's unlikely). Of course the rest of the path as well as query strings and fragments need to retained, for example:
projects/foo/dev/assets/js/jquery.min.js -> https://localhost/projects/foo/assets/js/jquery.min.js
This is my directory structure in my DocumentRoot folder:
- projects/
- foo/
- dev/
- dev1/
- dev2/
- dev3/
- bar/
- dev/
- dev1/
- dev2/
- and so on...
- foo/
I've tried the answer posted in this question but it isn't taking effect even after restarting Apache.
I've also tried this which seems correct but is giving me HTTP 500 with some infinite redirects error in error.log
:
RewriteEngine on
RewriteRule ^(.*)$ src/$1 [L,QSA]
I only have access inside each project directory (e.g. foo
and bar
) and the parent directory may not be called projects
on other machines. Therefore this needs to be done within htaccess files and not httpd.conf.