Virtual Subdomain,,, .htaccess

Started on the old forum in April 2008 · view the original in the archive · old links redirect here

17 replies · 2,465 views · started 18 years ago · 1 min read

TL;DR · summary of 17 replies
  • chatabox suggested using wildcard DNS to achieve the desired functionality without creating actual subdomains.
  • Wildcard DNS allows for a single domain to handle multiple subdomain requests by redirecting based on the requested URL path.
  • SpiderWap needs to ask their hosting provider to enable wildcard DNS, as it requires shell access which his current host does not provide.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

5 participants
SpiderWap Lead · 622 posts #1

I know theres a .htaccess code that i can use for this...

What i wana do is create a virtual subdomain. Example people register at my site builder script im coding...

the path would be like this http://siteurl.com/sites/index.php?username But i want it to be http://username.siteurl.com

So the .htaccess code should rewrite and make a redirect from http://username.siteurl.com to http://siteurl.com/sites/index.php?username

So if you for example put in http://anyword.siteurl.com it will redirect to http://siteurl.com/sites/index.php?username

Can someone please share this code with me?

amylee Principal · 1,092 posts #2

have a look at this link with explains how to do it with htaccess

http://www.webmasterworld.com/forum92/3555.htm
SpiderWap Lead · 622 posts #3

Thank you Amylee,,,,

you see, i have unlimited subdomains, had my script running before with php subdomain creation code but it made my surver untity, i had a folder for each user an had the surver create a php page with notice and link redirecting them to theyr sites, and i dont want it like that, but thanx for the url, ill have a look at it now.

SpiderWap Lead · 622 posts #6

Ok now while i been searching for the thing i want i found other .htaccess stuff that might be usefull to others.

IP bann

# someone else giving the ruskies a bad name..
order allow,deny
deny from 83.222.23.219
allow from all

Custom Error Pages

# custom error documents
ErrorDocument 401 /err/401.php
ErrorDocument 403 /err/403.php
ErrorDocument 404 /err/404.php
ErrorDocument 500 /err/500.php

Password protect an area

AuthType Basic
AuthName "restricted area"
AuthUserFile /usr/local/var/www/html/.htpasses
require valid-user
chatabox Senior · 361 posts #7

Read about "wildcard dns" on google, there is no need to even create any sub domains.. The mod rewrite method explained in the topic amy showed will still require real subdomains to exist or will cause a 404 error.

chatabox Senior · 361 posts #10

No bro im strugling lol call me stupid but for once im stuck actually very confused

If you want to do it without actually creating the subdomains you must learn about "wildcard dns" i had this same issue with a short url script i made.

If wildcard dns is enabled on a domain you will still land at the homepage even if you type blahhhhh.mysite.com you can then use php to check the requested url and redirect it based on the subdomain typed.

chatabox Senior · 361 posts #12

As i said just learn about it, wildcard dns is hard for me to explain, you will get far better info from google. You will need to get your host to enable it unless you have shell access as far as i know.

I can't really give a good code example without posting most of a personal script sorry.

Guest #17

lucky my site have SSH access so I can test the code myself

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close