Jump to content

Techniques for shortening URL with passed variables...


Guest kilbad

Recommended Posts

Question:: What techniques are avalible for shortening the overall URL length of an address with passed variables--other than shortening the variable name and its value?


The reason I ask is that I have coded a gallery script for myself, and the links are a bit long (for example:: [url=http://kilbad.com/index.php?id=photos&album=general]http://kilbad.com/index.php?id=photos&album=general[/url]).  I would like to make them shorter so I can more easily share them with family and friends.

I was just curious what other people with this problem have done.

Thanks so much in advance!
Brendan
You could use mod_rewrite for Apache. You can take your URL, http://kilbad.com/index.php?id=photos&album=general, and turn it into something like: http://kilbad.com/photos/general/

Here is a link to get you started with the basics.

http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html

There are other resources on the right column of the page to get you further if needed.

Jeremy
PERFECT!  Thank you so much..

however, here is a question, I am using the following code in my .htaccess, WITHOUT the [R]::

[code]
RewriteEngine on
RewriteRule ^photos/([^/\.]+)/?$ http://www.kilbad.com/index.php?id=photos&album=$1
[/code]

However, it still redirects...  for example, if I type http://www.kilbad.com/photos, I get redirected to http://www.kilbad.com/index.php?id=photos  which shows up in the address bar..  how do I keep the second link hidden and keep the http://www.kilbad.com/photos in the address bar?
you are absolutely right, that was not the full code...  here is my complete code..


[code]
RewriteEngine on
RewriteRule ^photos/([^/\.]+)/?$ http://www.kilbad.com/index.php?id=photos&album=$1
RewriteRule ^photos$ http://www.kilbad.com/index.php?id=photos
RewriteRule ^photos/$ http://www.kilbad.com/index.php?id=photos
[/code]

..but I still have the same question.. how do I keep the, for example, "http://www.kilbad.com/photos" in the addressbar rather than the "http://www.kilbad.com/index.php?id=photos"? 

Thanks so much for the help!
Brendan

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.