Hi all,
I setup 7 websites under one CMS. The website isn't live yet, correct url looks like that:
http://xx.xxx.xxx.xx./domain.com/
To make it works with subdomains, I add this to my windows/system32/drivers/etc/hosts file (Win 7):
xx.xxx.xxx.xx www.domain.com
xx.xxx.xxx.xx sub1.domain.com
xx.xxx.xxx.xx sub2.domain.com
xx.xxx.xxx.xx sub3.domain.com
xx.xxx.xxx.xx sub4.domain.com
xx.xxx.xxx.xx sub5.domain.com
xx.xxx.xxx.xx sub6.domain.com
On my hosting package I created subdomains: sub1, sub2..., and I pointed them to root dir, so all are pointed to the same directory public_html
To test it I upload tmp.php file where I put phpinfo(), and for each domain/subdomain ***.domain.com/tmp.php is fine.
In ModX I created new 6 contexts, 1 was set defauld when I install CMS.
For each context I set this:
base_url - /
http_host - sub*.domain.com
site_start - (homepage ID of the current context)
site_url - http://sub*.domain.com/
In root dir I made copy of index file, and in each file I changed
$modx->initialize('web'); to mach new context names (names are without spaces).
Below is my .htaccess file:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^index.php [NC]
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^sub1\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^sub1.php [NC]
RewriteRule ^(.*)$ sub1.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^sub2\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^sub2.php [NC]
RewriteRule ^(.*)$ sub2.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^sub3\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^sub3.php [NC]
RewriteRule ^(.*)$ sub3.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^sub4\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^sub4.php [NC]
RewriteRule ^(.*)$ sub4.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^sub5\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^sub5.php [NC]
RewriteRule ^(.*)$ sub5.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^sub6\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^sub6.php [NC]
RewriteRule ^(.*)$ sub6.php?q=$1 [L,QSA]
When I go to
http://sub1.domain.com/ it show me wrong page. For each subdomain, on screen I see homepage for main website (web -
http://www.domain.com/). When I go to contact us, on screen I have correct page, which means that htaccess point subdomains correctly (maybe not for homapage if there is nothing to pass by url/get - sub*.php?q=$1, I'm not sure). 3 pages are on each website: "home", "contact us" and "where can i buy it", but only for "home" page it always show the same page on each "website".
I tried to clear cache from CMS, I removed everything from /core/cache, I run cmd command on my laptop
, I also removed all temp files from my system disc. Nothing help. I also add to hosts file the same lines as I did on mine on another machine (MacBook Pro) but I didnt clear cache etc, and sometimes when I am on
http://sub1.domain.com/contact-us.html and click on "where i can buy it" it take me to
http://sub3.domain.com/where-can-i-buy-it.html, but I recon it's cache problem.
How do I diaply correct homepage for each subdomain?
If you want to know ip address/domain name, please send me PM.
Any additional info I didn't mention, just ask. Thank you all for any help and ideas.
[ed. note: batyrex last edited this post 13 years, 6 months ago.]