Welcome Guest, Not a member yet? Register   Sign In
Linking to my site with a ?var=val style url (Solved)
#1

[eluser]laytone[/eluser]
I have an affiliate site (clickbank) linking to my site.

When somebody click on clickbanks affiliate address link it hops them to my website like this:

http://mysite.com/?hop=affiliateid

Of course this is throwing a 404. I don't need the hop variable they send it in case I need but they send it no matter what. What can I do? Can i set up a rout that will just redirect them to my home page. How would I do this correctly?

Thanks in advance.

Layton
#2

[eluser]daparky[/eluser]
What you need to do is open the config.php file located in the application/config directory and change this:

Code:
$config['uri_protocol']    = "AUTO";

to

Code:
$config['uri_protocol']    = "QUERY_STRING";

and then change this:

Code:
$config['enable_query_strings'] = FALSE;

to

Code:
$config['enable_query_strings'] = TRUE;

Or, check this out: http://ellislab.com/forums/viewthread/56389/#277621
#3

[eluser]laytone[/eluser]
If I do this will my normal /controller/method/var/var2 URIs still work?
#4

[eluser]daparky[/eluser]
As far as i remember they should still work, give it a try and let me know how you get on. It's worth taking a look through this thread: http://ellislab.com/forums/viewthread/56389/#277621
#5

[eluser]laytone[/eluser]
My uri segmants still work, and I no longer get a 404.

But I do get this error:
The URI you submitted has disallowed characters.

How can I remap it now?
#6

[eluser]daparky[/eluser]
What parameter is the affiliate site passing back to yours?
#7

[eluser]BrianDHall[/eluser]
In the config file there is a list of allowed characters, something like this:

Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-\-\?&=;,';

Yours won't look like that, but mine is setup this way for debugging (those two dashes look the same, but they are actually different UTF-8 encoded versions of a dash that was throwing errors in my system - go figure).

So just add the characters that need to be passed gently to your site to this string in config.php and that should do it.
#8

[eluser]laytone[/eluser]
I have been able to solve my problem and here is how. (All thanks to daparky)

Using this post:
http://ellislab.com/forums/viewthread/56389/#277621

and this code from that post:

config file:
$config['uri_protocol'] = "PATH_INFO";

Extend Input Class:
class MY_Input extends CI_Input {

function _sanitize_globals()
{
$this->allow_get_array = TRUE;
parent::_sanitize_globals();
}

}

I can access the variable with this:
$this->input->get('varName') and Everything works like gold.
#9

[eluser]daparky[/eluser]
[quote author="laytone" date="1253143866"]I have been able to solve my problem and here is how. (All thanks to daparky)

Using this post:
http://ellislab.com/forums/viewthread/56389/#277621

and this code from that post:

config file:
$config['uri_protocol'] = "PATH_INFO";

Extend Input Class:
class MY_Input extends CI_Input {

function _sanitize_globals()
{
$this->allow_get_array = TRUE;
parent::_sanitize_globals();
}

}

I can access the variable with this:
$this->input->get('varName') and Everything works like gold.[/quote]

Glad i could help.
#10

[eluser]patwork[/eluser]
And here's my solution. Note that everything from first '&' to end of the uri is removed.

Code:
class MY_URI extends CI_URI
{

    function _fetch_uri_string()
    {
        parent::_fetch_uri_string();
        $pos = strpos($this->uri_string, '&');
        if ($pos !== FALSE)
        {
            log_message('debug', 'Removing invalid URI args from '.$this->uri_string);
            $this->uri_string = ($pos == 0 ? '' : substr($this->uri_string, 0, $pos));
            if ($this->uri_string == '/')
            {
                $this->uri_string = '';
            }
        }
    }

}




Theme © iAndrew 2016 - Forum software by © MyBB