Redirection controller |
[eluser]frist44[/eluser]
I'm looking to make a redirection controller, so that each link going to an external will be recorded in the logs. My thought is to make it of the form: www.domain.com/redir/url/http://website.com However, if I try to query the last uri segment, I get "http:" because the next slash looks like another segment. Any ideas to get this all as one string? I suppose I could str replace the "/" in the URL with something else, but didn't know if there were better ideas.
[eluser]Andrew Cairns[/eluser]
hi frist, you could just remove the http:// and just do domain.com/redir/url/www.google.com/ if needed, you could add the http:// when it redirects from the controller.
[eluser]frist44[/eluser]
But what if the actual URL itself had a slash in it. Ex. www.google.com/finance
[eluser]Andrew Cairns[/eluser]
you could try urlencode() : http://php.net/manual/en/function.urlencode.php
[eluser]frist44[/eluser]
I tried urlencode, but when I encode it, the system still interprets it as a "/" and says it can't find that function. In my code I have: Code: redirection('www.google.com/finance'); Helper: Code: function redirection($strURL) { Controller: Code: function url() {
[eluser]Andrew Cairns[/eluser]
you could append the rest of the uri segments if $this->uri->total_segments() > 3
[eluser]frist44[/eluser]
good idea. I did that and then had to put everything back together. Code: if ($this->uri->total_segments() > 3 ){ |
Welcome Guest, Not a member yet? Register Sign In |