Custom URL
Hi
Its been bugging me with problems but how can I achieve custom urls for my profile based website.
I want to provide users with their own domain for example:
myprofilewebsite.com/username
Is this a server side scripting issue or is there a better? or easier way around this?
Many thanks
demonhale posted this at 04:04 — 24th January 2006.
He has: 3,278 posts
Joined: May 2005
use folders for the one you want
, or better yet use subdomains... like username.myprofilewebsite.com
Busy posted this at 09:01 — 24th January 2006.
He has: 6,151 posts
Joined: May 2001
Do you want to give them their own webpage/server space or just use the URL as a personal page, example domain.not/username/ is really domain.not/page.fmt?user=person (which can be done with mod_rewrite in .htaccess)
cnlifeasitis posted this at 12:18 — 24th January 2006.
They have: 2 posts
Joined: Jan 2006
I would like to give the 'appearance' that 'http://www.website.com/username' is their personal webpage.
Then they can tell their friends: "Hey you can look at my website by going to, http://www.website.com/myusername" and then the reader can go to their profile directly by enterining the direct URL.
timjpriebe posted this at 14:27 — 24th January 2006.
He has: 2,667 posts
Joined: Dec 2004
So is it something where right now the URL looks like:
http://www.website.com/index.php?userid=myusername
If so, an .htaccess rewrite of the URL should be what you're looking for. I have not done that myself yet, but have started researching articles in preparation for a project I'm going to be working on. Here's one of the sites I've bookmarked:
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
Tim
http://www.tandswebdesign.com
robbluther posted this at 14:30 — 24th January 2006.
He has: 73 posts
Joined: Jan 2006
That would require a seperate folder and index file I believe... So you would have to create one for each username.
timjpriebe posted this at 14:40 — 24th January 2006.
He has: 2,667 posts
Joined: Dec 2004
The htaccess rewrite would not necessarily require a seperate folder and index file. It definitely would not require one for each username. That's the whole point.
I didn't understand this very well until a couple of days ago. But what an htaccess rewrite can do is take this:
http://www.website.com/myusername
and change it behind the scenes to this:
http://www.website.com/index.php?userid=myusername
So you don't see the url with parameters passed, but your index.php does see the url parameter userid=myusername. You just have the one index.php file, but to those who visit your website, it looks like you have lots of subdirectories.
Let's say you also had a file called "aboutus.php" that you also wanted to be unique for each user. Same thing, fortunately! The .htaccess file can rewrite:
http://www.website.com/myusername/aboutus
into
http://www.website.com/aboutus.php?userid=myusername
Tim
http://www.tandswebdesign.com
robbluther posted this at 14:42 — 24th January 2006.
He has: 73 posts
Joined: Jan 2006
Tim, Do you have any documentation on ataccess does that? I could use tht on my site.
demonhale posted this at 14:57 — 24th January 2006.
He has: 3,278 posts
Joined: May 2005
if you have no absolute paths, or session ids in your URL then you would need to modify your htaccess file... If you only mean to have that appearance in your URL then, a folder with an index file would do that simply...
timjpriebe posted this at 15:41 — 24th January 2006.
He has: 2,667 posts
Joined: Dec 2004
Rob: Yes, the link I posted before. Also, I've installed Drupal and other CMS's (but mostly Drupal) and they have that feature. They call it "clean URLs," I believe.
Here's the link again: http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
Tim
http://www.tandswebdesign.com
Greg K posted this at 18:10 — 24th January 2006.
He has: 2,145 posts
Joined: Nov 2003
CN, to clear things up here, please let us know:
1. Do you already have these pages set up or are you just getting ready to do them.
2. If they already exist, can you give a sample URL to a page that you CAN access that you want to be changed to the format www.domain.com/username
3. If you are just getting ready, what type of pages will there be? (ie does each person have their own pages (static or otherwise) or are teh individual pages going to be part of some system to manage the content?
-Greg
PS, after googling your username, I see you were asking on a lot of other sites back in march about creating an online community, so I'm guessing here that you would not be having each person having their own pages.
MyFreeCounter posted this at 21:17 — 27th January 2006.
They have: 7 posts
Joined: Jan 2006
as timjpriebe has described, mod_rewrite (an Apache module) is what can do that for you. Mod rewrite can catch all requests meeting a certain regular expression. So you can have mod_rewrite catch all URLs trying to access your site that have all letters or numbers, followed by a '.html', or a '/' or a '.user'. You do need an apache web server (to use mod_rewrite, apparently there are other versions of this for other servers).
But I would recommend that you have the user URLs be:
http://www.yoursite.com/users/SuperCoolDude423
instead of
http://www.yoursite.com/SuperCoolDude423
The reason for this is that you will have quite a hard time trying to only filter out requests for user's pages. There isn't any easy way to neglect your real URLs (http://www.yoursite.com/index.html) from being cought by mod_rewrite.
to use mod_rewrite, as stated, you need an apache box, most likely linux or unix OS. You also need to have it compiled with your server. Most hosting companies will recompile with it if you ask them. Once you have that set, you simply have to create a file in your root directory with the name '.htaccess'. In that file, you write your rewrite rules. Here is apache's guide on mod_rewrite:
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
Good luck!
Matt Pegler
MyFreeCounter Owner/Operator
http://www.MyFreeCounter.net - free hit, realtime, and click counters, as well as statistics
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.