<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# http|https www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^(.*)$ http%1://domain.com/$1 [R=301,L]
# redirect all subdomains
RewriteCond %{HTTP_HOST} !^domain\.(.*)$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ /%{HTTP_HOST}/$1 [NC,L,NS]
RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/public_html/sub1.domain.com/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/%{HTTP_HOST}
RewriteRule ^%{HTTP_HOST}(.*)$ /$1
RewriteCond %{HTTPS} on
RewriteRule ^$ %{HTTP_HOST}/app/webroot/ [L]
RewriteCond %{HTTPS} on
RewriteRule (.*) %{HTTP_HOST}/app/webroot/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/public_html/sub1.domain.com/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/public_html/sub1.domain.com/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ %{HTTP_HOST}/index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
RewriteEngine on
RewriteBase /
# http|https www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^(.*)$ http%1://domain.com/$1 [R=301,L]
# redirect all subdomains
RewriteCond %{HTTP_HOST} !^domain\.(.*)$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ /%{HTTP_HOST}/$1 [NC,L,NS]
RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/public_html/sub1.domain.com/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/%{HTTP_HOST}
RewriteRule ^%{HTTP_HOST}(.*)$ /$1
RewriteCond %{HTTPS} on
RewriteRule ^$ %{HTTP_HOST}/app/webroot/ [L]
RewriteCond %{HTTPS} on
RewriteRule (.*) %{HTTP_HOST}/app/webroot/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/public_html/sub1.domain.com/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/public_html/sub1.domain.com/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ %{HTTP_HOST}/index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Thanks a ton for posting this. I spent the last two days trying to get my subdomain htaccess files to play nicely with Cake. Cheers
ReplyDeleteAlways welcome :)
ReplyDeletenot for me
ReplyDelete