Forum Moderators: phranque
This works fine in practice except for one directory. For some reason it does something strange when it redirects:
[subdomain.domain.com...]
Redirects to [subdomain.domain.com...]
[subdomain.domain.com...]
Redirects to [subdomain.domain.com...]
It's only happening with this one subdirectory, not with any of the other subdirectories under subdirectory1.
I removed all of the .htaccess files from the directory structure leading up to that directory (including the one from my main domain) and only having one .htaccess for the subdomain which has the following rules in it:
RewriteEngine on
RewriteCond %{HTTP_HOST} otherdomain.org [NC]
RewriteRule (.*) [subdomain.domain.com...] [R=permanent,L]
RewriteCond %{HTTP_HOST} ^www.subdomain.domain.com [NC]
RewriteRule (.*) [subdomain.domain.com...] [R=permanent,L]
And the effect still occurs on subdirectory2. At this stage I'm stumped. I can't see anything in the rewrite rules which would behave differently for a particular subdirectory. My only theory is that the directory name is triggering some strange effect in Apache.
Look at the DirectoryIndex directive (if any) in .htaccess in the afflicted subdirectory, and be sure that the index filepath is a local URL-path, not including the DocumentRoot path.
A work around might be to add a rule to force a trailing slash on directory requests.
The double-slash in the incorrectly-rewritten URL smacks of a server misconfiguration.
Jim
I believe the reason is because when it came to evaluate:
RewriteCond %{HTTP_HOST} ^www.subdomain.domain.com [NC]
RewriteRule (.*) [subdomain.domain.com...] [R=permanent,L]
$1 ended up as the URI relative to the directory, not relative to the root of the subdomain, even though the rule being executed was in the .htaccess in the root directory of the subdomain.
Lesson learned. :)