Wildcard subdomain to file htaccess
- by Mikkel Larson
I've have a problem with a htaccess wildcard redirect
My base configuration is set to work with:
www.domain.com and domain.com
this is governed by 2 .htaccess files:
1: /home/DOMAIN/public_html/.htaccess
AddDefaultCharset utf-8
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?festen.dk$
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1
RewriteCond %{HTTP_HOST} ^(www.)?festen.dk$
RewriteRule ^(/)?$ public/index.php [L]
2: /home/DOMAIN/public_html/public/.htaccess
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Now i want to redirect:
www.[SUBDOMAIN].domain.com/[PATH] and [SUBDOMAIN].domain.com/[PATH] to
public/index.php/subdomaincontroller/realsubdomain/[PATH]
My solution so far:
Added following to 2: /home/DOMAIN/public_html/public/.htaccess
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+)domain.com [NC]
RewriteRule (.*) subdomaincontroller/realsubdomain/%2/$1 [L]
</IfModule>
Sadly this dows not work.
Can anyone help me please?