1

I would like to create virtual sub domains for clients who will have websites with us but the websites will be served from a single url in reality for example;

Customer requests website robshop.mywebsite.com so we create that on the fly but the content is actually served from mywebsite.com/websites/index.php?website=robshop

How do i do this?

Also my setup is with PHP and cPanel / WHM server.

Here is the htaccess code i have tried so far;

RewriteEngine On
RewriteCond %{HTTP_HOST} ^robshop.instamob.co.uk
RewriteCond %{REQUEST_URI} !instamob.co.uk/websites/index.php?website=robshop
RewriteRule ^(.*)$ instamob.co.uk/websites/index.php?website=robshop$1 [L]
Rob Kelly
  • 21
  • 1
  • 4

1 Answers1

1

Place this in a .htaccess file in your top directory:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^robshop.instamob.co.uk
RewriteCond %{REQUEST_URI} !websites/
RewriteRule ^(.*)$ websites/$1 [L]

If you need that $_GET submission, then you need to create a directory inside websites for each subdomain (ie instamob.co.uk/websites/robshop/) and then have an index.php for that directory that you want to show

Max Hudson
  • 9,961
  • 14
  • 57
  • 107