Subdomains and htaccess

  • DavyDuke17
  • Graduate
  • Graduate
  • DavyDuke17
  • Posts: 166

Post 3+ Months Ago

I believe I can achieve the following with htaccess but am not positive, so I was hoping someone could let me know and maybe help me out.

What I want to do is if someone accesses the following page on my website test.domain.com they are actually viewing the file domain.com/x.php?subdomain=test . If this is possible I'd also like to have test.domain.com/test2 refer to domain.com/x.php?subdomain=test&&page=test2

thanks!
  • cipher
  • Graduate
  • Graduate
  • User avatar
  • Posts: 157

Post 3+ Months Ago

I am not sure how you would do this with htaccess since I don't have Apache, but what you can do is have a wildcard CNAME in your DNS record such as *.your-site.com

Then you can extract subdomains using something like

Code: [ Select ]
list($subdomain) = explode('.', $_SERVER['HTTP_HOST'], 2)


http://www.your-site.com -> www
http://your-site.com -> your-site
http://test.your-site.com-> test

This is only one solution. The pitfall here is that you have to eliminate www and your-site. Experimenting would reveal other ways.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 52 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.