What is the best method to rewrite anything below "/some/subdir" to "/some/subdir/projects" like from this:
http://www.mydomain.com/some/subidr/test/
... to this:
http://www.mydomain.com/some/subdir/projects/test/
I found a similar question posted, but the solution didn't seem to work in my case. My current attempt so far (which doesn't seem to work):
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/projects/.*$
RewriteRule ^(.*)$ /projects/$1 [L]
EDIT: I forgot to mention the .htaccess file would have to be sitting within /some/subdir as I don't have write access to the server's web root.
Try this rule in your .htaccess configuration file in the document root of your server:
As you want to use this rule in your
/some/subdir/
directory, change the rule as follows:And if you want to redirect any requests of
/some/subdir/projects/
foobar
to/some/subdir/
foobar
, put this rule above the previous mentioned:I would use this:
This will redirect
/some/subdir/<anything>
to/some/subdir/projects/<anything>
.Note that the leading
/
is actually required to match the beginning of the URL, unless you haveRewriteBase /
set somewhere.This is the solution I finally got to work: