You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Rap Achmed <ra...@gmail.com> on 2015/01/12 01:39:16 UTC

[users@httpd] Rewrite Subdomain to Userfolder without Loop

Hello,

I'm trying to rewrite subdomains to user folders and rewriting the
"rootdomain" to some other domain:

RewriteCond %{HTTP_HOST} ^mydomain\.tld [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.tld
RewriteRule ^(.*) http://otherdomain\.tld [L]

RewriteCond %{HTTP_HOST} !^www\.mydomain.tld$
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.tld$ [NC]
RewriteRule ^(/[^\s]+)? http://www.mydomain\.tld/%1$1  [P,L]

what happens here is that my rewrite goes well from:

subdomain.mydomain.tld -> http://mydomain.tld/subdomain

But than it loops into ^mydomain.tld again and redirects to:

http://www.otherdomain.tld/subdomain

What am I doing wrong here?

Rap