2012-07-30 60 views
0

我想要什麼創建子域:如何使用CakePHP

http://mydomain.com/view/paris -> http://paris.mydomain.com 
http://mydomain.com/view/new-york -> http://new-york.mydomain.com 
etc 

我怎樣才能讓使用它的.htaccess,或者如果它存在,告訴我另一個解決方案。

P.S.對不起,我的英文。

回答

0

依賴於模型

https://gist.github.com/1498851

請閱讀的CakePHP它

http://pastebin.com/dJVj80mE

http://www.webmasterworld.com/apache/4046649.htm

Subdomain Redirect

//子域組件

或嘗試

重定向子域名CakePHP的行動

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^(.*).myserver.com$ [NC] 
    RewriteRule ^(.*)$ http://myserver.com/m/%1/$1 [L] 
</IfModule> 

RewriteCond %{HTTP_HOST} ^([^.]+).myserver.com$ [NC] 
RewriteRule (?!^m/$)^.*$ http://myserver.com/m/sites/%1%{REQUEST_URI} [NC,L,P] 

或者

RewriteEngine on 
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?dir\.domain\.com$ 
RewriteRule ^.*    http://domain.com/dir/$0  [R=301,L] 

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ 
RewriteRule ^dir/.*   http://domain.com/$0   [R=301,L] 
+0

那麼,它會將www.paris.mydomain.com重定向到www.mydomain.com/view/paris? @abidhussain – Scofield 2012-07-30 17:25:14

+0

我還沒有創建子域。我的意思是,如何使http://mydomain.com/view/paris將http://paris.mydomain.com,http://mydomain.com/view/new-york重定向到http:// new-york .mydomain.com等等。 @abidhussain – Scofield 2012-07-30 19:12:33