This redirection to subdirectories fails on some systems (e.g., Ubuntu/apache2, but was OK on FreeBSD/apache2?) for http://subdomain1.mydomain.com/subdirectory/otherpage
I get a FORBIDDEN error:
You don’t have permission to access /subdirectory/otherpage on this server.
I assume the rules I have in my .htaccess file just are not strong enough?
In post #3, I would have said that subdomain.domain/subdirectory SHOULD have given 404s because the subdomain is already directed to domain/subdirectory.
In post #4, you’re linking to subdomain.domain/private/file which, again, SHOULD fail.
What you need to do is provide a specification for yourself (and us) similar to:
Redirect subdomain1.domain/EVERYTHING to domain/subdirectory/EVERYTHING
AND
Redirect subdomain2.domain/EVERYTHING to domain/subdirectory/EVERYTHING
Then, when you test your mod_rewrite, test according to this pattern, NOT
subdomain1.domain/(subdirectory/EVERYTHING) and expect it to go to domain/subdirectory/EVERYTHING because it’ll be redirected to domain/subdirectory/subdirectory/EVERYTHING and that SHOULD result in a 404.
Of course, if your subdomains are set-up “normally,” they’re already serving domain/subdirectory/{REQUEST_URI} so this exercise should be moot.
I notice that when the redirect works, the URL bar resolves into mydomain.com/subdomain
but when I get the forbidden error it does not “resolve”; i.e., I still see the original address.
Next, my apologies. I thought I’d answered this earlier.
Finally, I have no idea why it works on one and not on the other - except that the test URL must be different (because the mod_rewrite needs some help):
RewriteBase is designed to UNDO a mod_alias Redirect. If you’re not using that, you don’t need the RewriteBase directive (one, let alone two!).
You need the Last flag in your first RewriteRule (otherwise, it’s ANDed with the next block which will ALWAYS fail that redirection because of the conflicting RewriteCond statements).
It probably is quicker to simply click on the following pages,
where I have mydomain->ingber, subdomain1->louise, subdomain2->creekhouse, page1=page2->louise_ballet.html, subdirectory->private, and otherpage->louise_private.html: