YOURLS/YOURLS — pull request #1560 by bmhm (2013-12-10 08:27:16+00:00)
Title: get rid of ugly parsing of request (for punycode)

Hey,

I was trying to install YOURLS to µ.mydomain.invalid. Now, this wouldn't work, because YOURLS tries to prepend YOURLS_SITE to the request uri, then cut it away afterwards. I don't think this is a good idea anyway.

Now I could fix it with setting YOURLS_SITE to xn--xxa.mydomain.invalid. But then, shortend links in the admin interface will have this ugly domain.

The best solution would be, in my opinion, not to have the request URI just pass "as it is", but as a value of a named parameter. This way there is no need to mess around with $_SERVER['REQUEST_URI'].

This method has some advantages:
1.) punycode will finally work!
2.) No messy handling of protocols, et al.
3.) It won't break anything else (nothing that I know of, needs testing).

Please, kindly review this patch. I'm very willing to modify it, if needed.
Also, don't forget to update https://github.com/YOURLS/YOURLS/wiki/.htaccess, if you pull.

--
Ben

PS: are you sure, $request should be static? IMO the function should be, but not the variable. If two parallel requests came to call the same function at the very same time, one of them might get redirect to the site of the other request.