Domainhandling via Rewrite

Using a single web hosting account to host multiple sites

Domainhandling via Rewrite

Postby hykoh » Sun Nov 02, 2008 11:32 am

Hello,

i've one page layout with various databases. The call atm looks like:

web.example.com/index.php?base=site1
web.example.com/index.php?base=site2
web.example.com/index.php?base=site3
web.example.com/index.php?base=site4

Now I want to bind the main domains on it (that they stay always in the adress bar).

So i need a rewrite like this:
www.myrealdomain.com/ -> /index.php?base=site1

The url must stay the same ... Can anyone help me ?

Best Regards
hykoh
 
Posts: 2
Joined: Sun Nov 02, 2008 11:17 am

Postby richardk » Sun Nov 02, 2008 2:11 pm

What happens for myrealdomain.com/some-path?
Do you have access to the httpd.conf file?

All the domains will need to have DNS and the same document root on the server. Then you can use something like
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?myrealdomain\.com$ [NC]
RewriteRule ^$ /index.php?base=site1 [QSA,L]


If you've got a lot of these domains and/or and more regularly, it's probably better to not use mod_rewrite and use the domain instead of base=site1 (use the HTTP_HOST variable in PHP instead).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby hykoh » Sun Nov 02, 2008 9:31 pm

yes i have root access ...

can i use ur pasted code also in the httpd.conf ? or is there any difference between httpd.conf rewrite and htaccess rewrite ?
hykoh
 
Posts: 2
Joined: Sun Nov 02, 2008 11:17 am

Postby richardk » Mon Nov 03, 2008 12:22 pm

Do you have <VirtualHost>s in your httpd.conf file? If not, try adding
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?myrealdomain\.com$ [NC]
RewriteRule ^/$ /index.php?base=site1 [QSA,L]


If you do, try adding
Code: Select all
<VirtualHost>
  ServerName   myrealdomain.com
  ServerAlias  www.myrealdomain.com
  DocumentRoot /path/to/your/document/root

  Options +FollowSymLinks

  RewriteEngine On

  RewriteRule ^/$ /index.php?base=site1 [QSA,L]
</VirtualHost>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 1 guest

cron