Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2009, 06:10 PM   PM User | #1
nickyfraggle
Regular Coder

 
Join Date: Mar 2006
Posts: 197
Thanks: 27
Thanked 2 Times in 2 Posts
nickyfraggle is an unknown quantity at this point
Dynamic short / search engine friendly URL's

Hello,

I'd like to use short URL's in my site. I've seen a lot of these online, programs that sort of amalgamate the parts of the long URL e.g. www.mysite.com/interests.php?user_id=12&access=2

What I'd really like, is if I could specify what the short URL should be e.g. myinterests, and that when someone typed in www.mysite.com/myinterests/ it would display the longer URL page (but not redirect them just display it). Is there a way where I can store the short url I'd like to relate to the 'long url' in a database, and when a page in the site is accessed it works out which page to actually display?

I don't know how to go about doing this, but I think it would be really helpful for Yahoo search results, and it looks MUCH nicer for users.

Any ideas? Any tutorials are good too. I've looked through quite a few, but none of them are dynamic i.e. they use htaccess files (which I'm guessing you can't update dynamically using php) to redirect the user to the right page. I'd like something that's completely dynamic.

Thanks,

Nicky
nickyfraggle is offline   Reply With Quote
Old 02-02-2009, 01:33 AM   PM User | #2
demtron
Regular Coder

 
Join Date: Jun 2008
Location: SE Wisconsin, US
Posts: 222
Thanks: 1
Thanked 20 Times in 20 Posts
demtron is on a distinguished road
I am not much of a PHP coder, but, from what I understand, one way to handle this is through modifying your .htaccess file. In ASP.Net (my expertise), you can create a custom HTTP handler to parse and rewrite the URL as needed or use the IIS 7.0 URL Rewrite module. Perhaps there are options like these in the PHP and Linux world?

Hope that helps!
__________________
Milwaukee Web Designer and SEO Milwaukee Firm specializing in ASP.Net, C#, VB.Net, SQL Server and Access.
demtron is offline   Reply With Quote
Old 02-02-2009, 06:07 AM   PM User | #3
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
Here is a good tutorial for you!!

http://www.addedbytes.com/apache/url...for-beginners/
kokjj87 is offline   Reply With Quote
Old 02-02-2009, 07:09 AM   PM User | #4
CyberPirate
Regular Coder

 
Join Date: Jan 2009
Location: Norway
Posts: 118
Thanks: 8
Thanked 2 Times in 2 Posts
CyberPirate is an unknown quantity at this point
Put this in .htaccess
Code:
RewriteRule ^interests/([0-9]*).*$ interests.php?user_id=$1
Use this link:
Code:
<a href="interests/$RandomUserID">$RandomUsername</a>
CyberPirate is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:54 AM.


Advertisement
Log in to turn off these ads.