Guest kilbad Posted October 14, 2006 Share Posted October 14, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23940-techniques-for-shortening-url-with-passed-variables/ Share on other sites More sharing options...
talreja_sapna Posted October 14, 2006 Share Posted October 14, 2006 i think u can try url redirection (mod_redirect) Quote Link to comment https://forums.phpfreaks.com/topic/23940-techniques-for-shortening-url-with-passed-variables/#findComment-108816 Share on other sites More sharing options...
jeremywesselman Posted October 14, 2006 Share Posted October 14, 2006 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.htmlThere are other resources on the right column of the page to get you further if needed.Jeremy Quote Link to comment https://forums.phpfreaks.com/topic/23940-techniques-for-shortening-url-with-passed-variables/#findComment-108818 Share on other sites More sharing options...
Guest kilbad Posted October 15, 2006 Share Posted October 15, 2006 PERFECT! Thank you so much..however, here is a question, I am using the following code in my .htaccess, WITHOUT the [R]::[code]RewriteEngine onRewriteRule ^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? Quote Link to comment https://forums.phpfreaks.com/topic/23940-techniques-for-shortening-url-with-passed-variables/#findComment-109044 Share on other sites More sharing options...
wildteen88 Posted October 15, 2006 Share Posted October 15, 2006 Well the rewriterule you have does not match http://www.kilbad.com/photosSo you must have someother rewrite rule doing the redirect for photos Quote Link to comment https://forums.phpfreaks.com/topic/23940-techniques-for-shortening-url-with-passed-variables/#findComment-109077 Share on other sites More sharing options...
Guest kilbad Posted October 15, 2006 Share Posted October 15, 2006 you are absolutely right, that was not the full code... here is my complete code..[code]RewriteEngine onRewriteRule ^photos/([^/\.]+)/?$ http://www.kilbad.com/index.php?id=photos&album=$1RewriteRule ^photos$ http://www.kilbad.com/index.php?id=photosRewriteRule ^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 Quote Link to comment https://forums.phpfreaks.com/topic/23940-techniques-for-shortening-url-with-passed-variables/#findComment-109120 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.