htaccess subdomain

Started by MrLeN, December 16, 2012, 03:29:58 AM

Previous topic - Next topic

MrLeN

Is it possible to load:

http://www.mywebsite.com/web/USERNAME/index.php

as:

http://username.mywebsite.com

?

..if so, can anyone show me how, or direct me to a page/explanation/tutorial that explains how?

I have a cPanel WHM reseller account, and I have access to change DNSstuff in WHM if I want/need to.

I have already seen some tutorials and I know I have to do wildcard DNS or something.

But it's all a bit hard for me, so I am just hoping that someone who knows what to do might be able to simplify it.

MrPhil

Aren't cPanel and WHM two different brands of control panel? Please don't use "cPanel" unless you're specifically referring to a cPanel installation.

All reasonably good control panels should give you a means to set up subdomains. Not all will let you dynamically create a new subdomain (without control panel usage), and many hosts will also not let you dynamically create subdomains, even if the control panel otherwise will let you. You could try entering http://myusername.mywebsite.com and seeing if an /.htaccess URL rewrite can get access to the URL before the host DNS rejects it as not existing. You still might need to have your host and/or control panel permit some kind of wildcard.

Your example sounds like you're going to install SMF in each USERNAME directory. What is the point of that? That would be even more labor than setting up individual USERNAME subdomains! Assuming you want to keep just one SMF installation, are you trying to set up the login to make it accessible by entering just the (fake) subdomain? That is, the user gets to the point where they have to enter only the password? That might be possible, if your hosting will let you intercept subdomain requests and rewrite them to a single common SMF installation. Perhaps you should elaborate on just what you're expecting the user experience to be here?

MrLeN

Quote from: MrPhil on December 16, 2012, 10:50:43 AM
Aren't cPanel and WHM two different brands of control panel? Please don't use "cPanel" unless you're specifically referring to a cPanel installation.

All reasonably good control panels should give you a means to set up subdomains. Not all will let you dynamically create a new subdomain (without control panel usage), and many hosts will also not let you dynamically create subdomains, even if the control panel otherwise will let you. You could try entering http://myusername.mywebsite.com and seeing if an /.htaccess URL rewrite can get access to the URL before the host DNS rejects it as not existing. You still might need to have your host and/or control panel permit some kind of wildcard.

Your example sounds like you're going to install SMF in each USERNAME directory. What is the point of that? That would be even more labor than setting up individual USERNAME subdomains! Assuming you want to keep just one SMF installation, are you trying to set up the login to make it accessible by entering just the (fake) subdomain? That is, the user gets to the point where they have to enter only the password? That might be possible, if your hosting will let you intercept subdomain requests and rewrite them to a single common SMF installation. Perhaps you should elaborate on just what you're expecting the user experience to be here?

WHM the Web Host Manager for cPanel. If I am going to change DNS settings, I would do that in WHM. cPanel is just the user control panel for a domain. I just say WHM cPanel, because that's how most people refer to cPanel.

Problem is, I don't want to break anything, and I don't know what htaccess to create to direct people to the subdomain.

As for what I am doing: I am not installing a board in every username directory. I am storing some files in those folders for a script that I am writing to read - so that each user can have a  simple web page. Basically, when someone joins the forum, I am storing some stuff in mywebsite.com/web/theirusername and then I want that to be accessible at: theirusername.mysite.com -- it's just a basic flat file web page, making use of their username. I am making it as a gimmick to get people to sign up. ie: sign up and you get a free web page! I think it will actually be very useful. I also think a lot of people would be interested -- because I will give them a forum section for the web page. So, the forum will be made of little forums for everyone who has a web page.

I also made a post at the cPanel WHM forum. It explains clearly what I want to do:

http://forums.cpanel.net/f5/wildcard-dns-htaccess-310632.html

No one has replied there yet, either.

If I can't get help, I will eventually try to do it myself, but I just KNOW I am going to destroy the whole server. I am ok at php and html, but not dns and server stuff (or htaccess).


MrPhil

I have cPanel, but no WHM. Maybe that's something for resellers only. I made the original comment because a lot of people are referring to any control panel as "cPanel" -- kind of like referring to any adhesive strip bandage as a "Band-Aid".

If you have wildcard DNS capability, I suppose you can tell users they have USERNAME.mysite.com and use /.htaccess to rewrite the URL to some real existing URL (such as a login point with the USERNAME already filled in).

Uh, if you are telling people that they have a free Web page, do they really get access to that page so that they can upload and run anything they want? Is that the actual intent, and the shared forum is kind of a byproduct?

Advertisement: