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;


main site:

domain.com/post/20/Posttitle
domain.com/index.php?r=post/20/Posttitle

sub site:

mysub.domain.com
domain.com/index.php?s=mysub

OR

mysub.domain.com/post/20/Posttitle
domain.com/index.php?s=mysub&r=post/20/Posttitle

OR

mysub.domain.com/Cat/2/cattitle
domain.com/index.php?s=mysub&r=Cat/2/cattitle

OR

mysub.domain.com/{OrderURL}
domain.com/index.php?s=mysub&r={OrderURL}

....

** In a general example: Blog system


How do i do this?

Also my setup is with PHP{Something like the MVC} and cPanel / WHM server.
Note: The design on localhost

Here is the htaccess code i have tried so far (does not work properly);

RewriteCond %{HTTP_HOST} ^(http://|https://)?(www\.)?(.*\.)?(.*)$
RewriteRule (http://|https://)?(www\.)?(.*\.)?(.*)$ index.php?s=$3&r=$4 [L,NC,QSA]

RewriteRule ^(.*)$ index.php?r=$1 [L,NC,QSA]
MONJE
  • 85
  • 11
  • what is the actual question? How to create a subdomain or how to use RewriteRule? – smnbbrv May 07 '15 at 09:03
  • Use RewriteRule  To create a virtual subdomain. for example site: sub.blogsky.com – MONJE May 07 '15 at 09:10
  • possible duplicate of [Create Subdomains on the fly with .htaccess (PHP)](http://stackoverflow.com/questions/586129/create-subdomains-on-the-fly-with-htaccess-php) – smnbbrv May 07 '15 at 09:20
  • Thanks, but the site structure does not allow the use of this solution. – MONJE May 07 '15 at 09:29

0 Answers0