How to shorten an URL in PHP?

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
bambinou
Forum Newbie
Posts: 2
Joined: Wed May 23, 2007 12:43 pm

How to shorten an URL in PHP?

Post by bambinou »

Dear all,

i am having a very big problem at the moment,someone is designing my future website and told me that one of my request was impossible.

they have created a website where bands will open an account and have their own page.the problem is i need the band name to follow the site url.
ie:
if the site is called:
http://www.thisismysite.com



and a band called bhfffr open an account with us,i would like the band to put their band name is a requiered input field and then get a url specially for them like this one:
http://www.thisismysite.com/bhfffr

and not something like i am actually having:
http://www.thisismysite.com/store.php/bhfffr

is this possible in php?

the programmers i have hired told me this could cause a security problem because the file name would be seen by everyone.

the question is:
how can big sites like http://www.soundclick.com provide this kind of service???

how does all of this work,has anyone an idea please????


thank you very much ,


regards to all.



ben
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

You are looking for an apache rewrite rule.

Code: Select all

RewriteEngine On
RewriteRule ^([a-z0-9]{3,25}$ band_page.php?band=$1
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

It is altogether possible as scottayy pointed out, and there aren't any security issues so long as sensitive data isn't exposed in the URL. Have your developer look up mod_rewrite.
bambinou
Forum Newbie
Posts: 2
Joined: Wed May 23, 2007 12:43 pm

Post by bambinou »

Thank you very much my friends for your help,
would it be possible to be a bit more specific on how to do something like this,this way i can show this forum to our programmers.
thank you very much !!!!


regards,


ben
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Tell your developer to come to this forum and search for mod_rewrite. That is all they need to know.
Post Reply