Hi all, I would like to automatically generate subdomains when a user registers. Unfortunately i know very little (jack sh*t) about mod_rewrite and .htaccess etc. But my plan is to open .htaccess with PHP when the user subscribes, and add some lines to make http://user.test.com refer to http://www.test.com/users.php?id=1 for example. Is this a good idea and if possible, can someone tell me what lines PHP has to write in .htaccess. Thx a lot!!
.htaccess code RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ! ^www\.test\.com [nc] RewriteCond %{HTTP_HOST} (.*)\.test.com [nc] RewriteRule /users.php?id=1% Code (markup):
i've got this code now: RewriteEngine on RewriteCond %{HTTP_HOST} ^$ [OR] RewriteCond %{HTTP_HOST} ^www.$ RewriteRule ^(.*)$ http://www.allsites.be/~test/index.html [R=301,L] RewriteCond %{HTTP_HOST} !^www\.test\.be RewriteCond %{HTTP_HOST} ^([^.]+)\.test\.be RewriteRule ^/?$ http://www.test.be/index.php?id=%1 [L] Code (markup): www.test.be itself refers to www.allsites.be/~test. but when i type frank.test.be it doesn't refer to www.test.be/index.php?id=frank it just says "Could not found server frank.test.be" help! (im such a noob at this)
You cant just add a rewrite you need to configure wildcard subdomains on your server like *.test.com so then * can be anything and generated on the fly.
Thx, got it to work now, but i can see the redirect. I'd like to keep the subdomain URL in the adres bar unchanged! (invisible redirect) this is the code i use now: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^$ [OR] RewriteCond %{HTTP_HOST} ^www.$ RewriteRule ^(.*)$ http://www.digx.be/~wieper/index.php [R=301,L] RewriteCond %{HTTP_HOST} !^w{3}\. RewriteCond %{HTTP_HOST} ^([^.]+)\.wieper\.be$ RewriteRule ^(.*)$ http://www.digx.be/~wieper/index.php?p=bedrijvengids&show=detailed&sub=%1 [L] Code (markup): You can see that there is already a redirect from the site domain i'm using to my main domain. When i go to http://visionline.wieper.be i go to http://www.digx.be/~wieper/index.php?p=bedrijvengids&show=detailed&sub=visionline which is just like http://www.wieper.be/index.php?p=bedrijvengids&show=detailed&sub=visionline But i want to keep http://visionline.wieper.be as URL? Or at least the www.wieper.be domain and not the digx domain.