Welcome Guest, Not a member yet? Register   Sign In
URL shortening service
#16

[eluser]jdfwarrior[/eluser]
Well theres different ways of doing it.

Certainly the way xwero is telling you is a valid way as well, I just mentioned the way with the _remap function because of the way you formed the other url. As an explanation of what I was talking about..

You would create your route:
Code:
$route['(:any)'] = snip/$1;

Then in your controller you would create a _remap function. It's purpose is to override index as the default function. Instead remap would be called and accept the next uri segment (supposed to be the function) as a parameter.

Code:
function _remap($url)
{

  if (is_valid_short_url($url)) {

    header('Location: '.get_long_url($url));

  }

  else {

    show_404();

  }

}

Obviously the url functions are made up, checking the database and such would be your own method, I was just showing an example. That would be in your snip controller and coupled with the route I mentioned, would allow you to access short urls via: http://domain.com/snip/<id> or with the route configured, http://domain.com/<id>


Messages In This Thread
URL shortening service - by El Forum - 06-02-2009, 02:36 AM
URL shortening service - by El Forum - 06-02-2009, 03:01 AM
URL shortening service - by El Forum - 06-02-2009, 03:02 AM
URL shortening service - by El Forum - 06-02-2009, 03:10 AM
URL shortening service - by El Forum - 06-02-2009, 04:13 AM
URL shortening service - by El Forum - 06-02-2009, 06:20 AM
URL shortening service - by El Forum - 06-02-2009, 06:44 AM
URL shortening service - by El Forum - 06-02-2009, 06:48 AM
URL shortening service - by El Forum - 06-02-2009, 06:56 AM
URL shortening service - by El Forum - 06-02-2009, 07:00 AM
URL shortening service - by El Forum - 06-02-2009, 07:19 AM
URL shortening service - by El Forum - 06-02-2009, 07:31 AM
URL shortening service - by El Forum - 06-02-2009, 07:44 AM
URL shortening service - by El Forum - 06-02-2009, 07:47 AM
URL shortening service - by El Forum - 06-02-2009, 07:53 AM
URL shortening service - by El Forum - 06-02-2009, 08:03 AM
URL shortening service - by El Forum - 06-02-2009, 08:11 AM
URL shortening service - by El Forum - 06-02-2009, 08:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB