Standard Setup With Required Rewrites On Shared Hosting

Hi,

I am running a Yii website, well 2 actually, on the same account. 1 is production, the other is test. each site shares the same Yii framework folder but has their own discreet site files, both sitting at the same level in the folder structure.

I had both sites working perfectly in another account but they were both sub domains. This time the prod domain is the main domain and the test domain is a sub domain.

I would have thought this would be a fairly typical setup and was hoping to find some generic walkthrough for this type of setup but havent been able to find anything.

So, site root folder for the account is \home\mydomain\public_html (where mydomain.com points to)

Yii framework folder: \home\mydomain\yii-1.1.14

PROD

root folder: \home\mydomain\public_html\mydomain.com

protected folder: \home\mydomain\public_html\mydomain.com\protected

www folder: \home\mydomain\public_html\mydomain.com\www

TEST

root folder: \home\mydomain\public_html\test.mydomain.com

protected folder: \home\mydomain\public_html\test.mydomain.com\protected

www folder: \home\mydomain\public_html\test.mydomain.com\www

At the moment, the site works fine however I am having trouble hiding "mydomain\www\" from the URL path.

For instance, the login menu item shows mydomain.com\mydomain.com\www\user\login as the path, instead of mydomain.com\user\login

As stated previously, this was working perfectly when it was set as a sub domain in another account.

I guess the difference is that now I have .htaccess in the root folder that points to domain.com\www as the site root, which bypasses the public_html\domain.com folder that was the site root in the previous config.

I presume I need:

.htaccess in public_html to point to domain.com/www

.htaccess in public_html/domain.com/www to hide the folders from the URL path?

any help would be appreciated

Regards

Greg J

the test.domain.com works perfectly because its a subdomain and I can set the dcoument root for this to the correct folder (public_html/test.mydomain.com/www).

HTACCESS in site root (public_html)




RewriteEngine on


Options -Indexes 


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule . index.php

RewriteRule ^(.*)$ /mydomain.com/www/$1 [L]



HTACCESS in prod site root (public_html/mydomain.com/www)




RewriteEngine on


Options -Indexes 


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule . index.php

RewriteRule ^(.*)$ /mydomain.com/www/$1 [L]



i ended up taking the easy way out on this. it just wasnt worth the effort

from what I can gather, what I am asking for is very complex and you really need to find someone who really knows this htaccess stuff to get it right. I dont have the solution yet and I still would like to know if it can be done.

What I ended up doing was i purchased another domain and made that domain the primary domain. I then added the old primary domain as an addon domain, where I can specify the document root for it. if you do this there is no messing around required with htaccess to get it working. The test domain is a subdomain of the addon domain so again, a document root can be specified and no htaccess required.

The new primary domain is complimentary to the site so I have created a redirect for this to the main domain.

So if you have more than one domain for your site, make the primary domain one of the domains that will be redirected to the main domain name, then make the main domain an addon.

Example:

Lets say you have 2 domains:

widgets.com will be the main domain where all the traffic lands and if anyone enters widgets.net then they will be redirected to widgets.com

create the hosting account using widgets.net as the primary domain

create an addon domain for widgets.com and make the document root \public_html\widgets.com\www

create a redirect from widgets.net to widgets.com (so nothing can land above widgets.com doc root)

if you want any subdomains of widgets.com, just create them and point them to their doc root inside public_html, ie: public_html/test.widgets.com/www

you can now put the framework folder inside public_html and it is outside and public facing domains doc root. your "protected" and "config" folders sit at the same level as the "www" folder so will be inaccessible from the web.




public_html

    yii-framework

    widgets.com

        www     <---- website root

        protected

        config

    test.widgets.com

        www     <---- website root

        protected

        config