TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   myusername.mywebsite.com (http://www.talkphp.com/general/4117-myusername-mywebsite-com.html)

ian ditch 04-09-2009 01:47 PM

myusername.mywebsite.com
 
hi people. my 1st post.

I've noticed that it is possible to have a varible before your site address, e.g. myusername.mywebsite.com

can anyone cast light on how to do this or what this is called so i can google it. I want to get away from using mywebsite.com/myusername and creating a seperate folder for each member in my root directory

thanks :-D

Village Idiot 04-09-2009 02:06 PM

Are you just asking what a subdomain is, or are you looking to make it dynamic? If you are looking to make it dynamic, mod_rewrite is probably your best option.

ian ditch 04-09-2009 04:50 PM

ha, right, its subdomains that i want.
after googleing this i realise i'm stepping into another minefield here.

all i'm after doing is to create a subdomain of 'username' instead of '/username' for a members area.

i would normally simply use mkdir("username", 0700) etc to make
a unique folder for each member (mainly for their images)but this fills the root directory full of folders so instead i'm looking at maybe using these subdomains?

is there a quick & simple way of using php to create a subdomian
and if so, what would the path to the image be?

Tanax 04-09-2009 05:52 PM

I believe PHP has nothing to do with the subdomains. That's something you have to ask your webhost provider.

allworknoplay 04-09-2009 08:35 PM

Quote:

Originally Posted by Tanax (Post 22958)
I believe PHP has nothing to do with the subdomains. That's something you have to ask your webhost provider.

Correct, this is not a PHP thing or any kind of variable thing.

What you are looking to do is create a subdomain.

that has to do with your hosting provider and DNS.

Where you store your directory "username" doesn't matter, as long as your provider is aware of it and your web server is configured to know that that directory is meant to be a subdomain...

anees_muhd 04-10-2009 04:13 AM

Quote:

Originally Posted by allworknoplay (Post 22970)
Correct, this is not a PHP thing or any kind of variable thing.

What you are looking to do is create a subdomain.

that has to do with your hosting provider and DNS.

Where you store your directory "username" doesn't matter, as long as your provider is aware of it and your web server is configured to know that that directory is meant to be a subdomain...

Yes..
But if you are lucky you can do it easily
Some of the providers will give catch all subdomain facility.
but some are not

in the first case we can logically manage the problem
that is you are not going to be create any subdomains, instead you will catch any string that comes in front of your domain and will manage with your file and treat them as usernames

So that you can check with your DB and perform appropriate actions...

Regards
Anees

jcorradino 04-10-2009 04:34 AM

you could always try a rewrite rule

RewriteRule http://(.*).yoururl.com http://www.yoururl.com/username=$1

just set your httpd.conf file as so (if it is your server, if not, your host can most likely set it up for you):

<VirtualHost *:80>
DocumentRoot "/path/to/www/"
ServerName *.yoururl.com
</VirtualHost>

dont hold me to it though, I have not messed around with Apache in a while, so I am bound to be a bit rusty.

If it does work, it will actually just see your "subdomain" as the php get variable username, in which case, you can just ignore www. Otherwise, you can always stick with the following (which I know works like a charm):

RewriteRule yoururl.com/(.*) yoururl.com/user.php?username=$1

dont forget RewriteEngine on and Options +FollowSymLinks though!


All times are GMT. The time now is 04:24 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0