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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.