I have fixed the problem, i am posting my solution so it might help
somebody.
So basically it turned out that my .haccess file should look something like:
<IfModule mod_rewrite.c>
    RewriteEngine on
        ## Check to see if the URL is without www part and its not a
predefined subdomain, then attach www part to HTTP_HOST
        RewriteCond %{HTTP_HOST} !^www\.
        RewriteCond %{HTTP_HOST} !^corp\.
        RewriteCond %{HTTP_HOST} !^static\.
        RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]

        ## Continue normally with CakePHP request cycle
        RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
        RewriteRule    ^$ app/webroot/    [L]
        RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
        RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

The only thing that bothers me on the above hack is that every request will
be checked to see if it matches one of the 3 conditions above but i think
that i can live with that for now.

Hope this will help somebody someday.

Thanks Guys.


On Sun, Oct 23, 2011 at 10:03 AM, Ma'moon <[email protected]> wrote:

> Hello Guys,
>
> I have a problem that i don't really know how to fix since am not really
> an apache nor mod_rewrite expert, i did my homework by researching and
> googling but with no luck so far.
> I need to create subdomains beside the directory that contains my CakePHP
> installation, right inside the directory that contains the first .haccess
> file that redirects all requests to app/webroot, my .htaccess content is as
> follows:
>
> <IfModule mod_rewrite.c>
>     RewriteEngine on
>         ## sub-domains section
>         RewriteCond %{HTTP_HOST} ^corp\.
>             RewriteRule    ^$ subdomains/corp/    [L]
>             RewriteRule    (.*) subdomains/corp/$1 [L]
>         ## instead of example.com lets redirect the request for a 301
> page with URL www.example.com
>         RewriteCond %{HTTP_HOST} !^www\.
>             RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
>     ## CakePHP section
>     RewriteEngine on
>         RewriteRule    ^$ app/webroot/    [L]
>         RewriteRule    (.*) app/webroot/$1 [L]
> </IfModule>
>
> in the holder directory for the above .hatccess file i have a folder
> called subdomains, inside that folder i have other folders that contains
> some applications, for example the "corp" folder is a wordpress
> installation, i also have static folder that contains JS and CSS files so
> that they will be requested from a subdomain instead of the same domain
> that the page lays on, this is basically to make use of concurrent browser
> requests.
>
> Having this .htaccess content makes my server produce 500 internal server
> error and my whole CakePHP application goes down beside having the
> subdomains unfixed.
> Am not really sure where the problem exactly is so i thought may be
> somebody have passed through this before then i will thankful if he/she may
> share the experience on resolving this issue.
>
> Perhaps i must also mention that my server is a shared host and its
> running CakePHP 1.3
>
> Thanks a lot.
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to