Parse URL

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
teezilla
Forum Newbie
Posts: 6
Joined: Tue Feb 03, 2009 2:48 pm

Parse URL

Post by teezilla »

Hello all.. I'm an intermediate php developer and I'm just having mental block kind of a day.

I'm just trying to parse_URL http://www.someurl.com/directory/214 for the last digits in the url and use them in a my sql db as the URL_ID. Also redirect that url to another page..

Any help would be greatly appreciated.

Thanks

TeeZilla :oops:
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Parse URL

Post by requinix »

Sounds like you have some kind of URL rewriting going on. In which case, fix the rewriting scheme so that your PHP script gets the ID number directly.

Code: Select all

RewriteRule ^/?directory/(\d+)/?$ /directory/index.php?id=$1 [QSA]
index.php gets the ID with $_GET["id"].
teezilla
Forum Newbie
Posts: 6
Joined: Tue Feb 03, 2009 2:48 pm

Re: Parse URL

Post by teezilla »

Thanks so much tasairis. I'll give that a try..
Post Reply