...

View Full Version : Dynamic short / search engine friendly URL's



nickyfraggle
02-01-2009, 07:10 PM
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

demtron
02-02-2009, 02:33 AM
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!

kokjj87
02-02-2009, 07:07 AM
Here is a good tutorial for you!!

http://www.addedbytes.com/apache/url-rewriting-for-beginners/

CyberPirate
02-02-2009, 08:09 AM
Put this in .htaccess

RewriteRule ^interests/([0-9]*).*$ interests.php?user_id=$1

Use this link:

<a href="interests/$RandomUserID">$RandomUsername</a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum