Skip to content

Instantly share code, notes, and snippets.

@ozh
Last active October 13, 2022 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozh/1d078e9cbd5f9757be3bb32011c48461 to your computer and use it in GitHub Desktop.
Save ozh/1d078e9cbd5f9757be3bb32011c48461 to your computer and use it in GitHub Desktop.
YOURLS plugin: keep query string
<?php
/*
Plugin Name: Keep Query String
Description: Adds short URL query string, if any, to the long URL
Version: 0.1
Author: Ozh
*/
yourls_add_filter('redirect_location', 'ozh_kqs');
function ozh_kqs($url){
if (yourls_is_GO()) {
$url = yourls_add_query_arg($_GET, $url);
}
return $url;
}
// well I think that's it
@congthien
Copy link

congthien commented Jan 14, 2019

I'm not sure what the consequences of this are, but I managed to avoid the double encoding by duplicating the yourls_add_query_arg() function and commenting out the line that performs the reencoding (the call to yourls_urlencode_deep()).

Here's the full version: https://gist.github.com/rinogo/345dcfb149f1020f501b262ff45035d2

Thank you so much for your code. That is what I need :)

@rinogo
Copy link

rinogo commented Mar 20, 2020

@congthien I've released an updated version of the plugin: YOURLS Keep Query String

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment