Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter not appending #1

Open
m7ess5 opened this issue Sep 7, 2017 · 3 comments
Open

Parameter not appending #1

m7ess5 opened this issue Sep 7, 2017 · 3 comments

Comments

@m7ess5
Copy link

m7ess5 commented Sep 7, 2017

hi,

the append function is not working.

long URL

https://example.com/the-coaching-zone/melbourne/?myVar=222

short URL

https://example.com/added-vars

when i use

https://example.com/added-vars?add-this-var=1

it doesn't add it.

thanks

@enoversum
Copy link

Same here. Parameters are just not added to the long URL.

@skarjoss
Copy link

skarjoss commented Feb 14, 2022

I was deeping dive at this issue, in my case I noticed PHP v7 for some reason does not return any value in $_SERVER['QUERY_STRING'], and all yourls query_string plugins I have seen relies on $SERVER variable.

A solution was to edit the plugin.php, and replace $queryString = $_SERVER['QUERY_STRING'] with $queryString = getServerQueryString();

And then create this function in same file plugin.php:

function getServerQueryString()
{
    if(isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])){
        return $_SERVER['QUERY_STRING'];
    }
    elseif(isset($_SERVER['REQUEST_URI'])) {
        $xpl = explode('/', $_SERVER['REQUEST_URI']);
        $baseName = $xpl[end(array_keys($xpl))];
        if(strpos($baseName, '?') !== false){
             return substr($baseName, strpos($baseName, '?')+1);
        }
    }
    return null;
}

@littleskyfish
Copy link

Thanks for this comment,I made a plugin query-string-keeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants