Skip to content

Instantly share code, notes, and snippets.

@souparno
Created October 5, 2014 08:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souparno/02669dbe1e4ed2137935 to your computer and use it in GitHub Desktop.
Save souparno/02669dbe1e4ed2137935 to your computer and use it in GitHub Desktop.
.htaccess file ,subdomain and cakePHP
onsider a domain www.example.com. You have created an appliaction in its root folder.
Now you purchase a new subdomain www.newdomain.net that is like root/newdomain/ in your server.
When you place your cake application inside this newdomain folder, you will encounter problem regarding
redirect, sometimes you css will be not getting loaded same is with javascript and images.
To overcome this problem create 3 .htaccess files in this order:-
1) .htaccess file in root/newdomain/ folder write this:-
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
2).htaccess file in root/newdomain/app/ folder write this:-
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
3) .htaccess file in root/newdomain/app/webroot/ folder write this:-
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
save these files and we are done. Your new subdomain www.newdomain.net must now be working fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment