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
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.
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?
I believe PHP has nothing to do with the subdomains. That's something you have to ask your webhost provider.
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...
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...
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):
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