User friendly URL using htaccess

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sunil_23413
Forum Newbie
Posts: 10
Joined: Thu Mar 12, 2009 5:43 am

User friendly URL using htaccess

Post by sunil_23413 »

Hello
I am working on a site http://mygradregistry.com.
When user goes to link " http://mygradregistry.com/username "
then it should display the content of page "http://mygradregistry.com/profile.php" .
How I can achieve this requirement?
If htaccess is the best method then how I can do it with htaccess?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: User friendly URL using htaccess

Post by requinix »

Okay, but I have a question: what if /username already exists? What if the username is "images"?
ricehigh
Forum Newbie
Posts: 21
Joined: Mon Sep 14, 2009 5:18 pm

Re: User friendly URL using htaccess

Post by ricehigh »

I've seen many websites overcoming the problem tasairis describes by assigning a tilde before the username, which means:
This url:
domain.com/~<the username>
becomes this url:
domain.com/profile.php?username=<the username>

I'm sure this site can help you create the proper .htaccess file: http://corz.org/serv/tricks/htaccess2.php

EDIT: alternatively you can have: domain.com/user/<the username> becoming domain.com/profile.php?username?<the username>
Post Reply