Separate install from public access



I need to set up a short link handler from my public site in a subfolder https://public-url.local/go/{{short-link}}, however due to how the site is built I cannot host yourls on the public site.

Is there a way to install the yourls admin/database on one domain/subdomain whilst setting generated shorturls to resolve via a different domain/subdomain?

Here’s where I am so far…

For reference I am testing all of this locally using xampp

So I have set domain https://short-site.local and managed to get my apache vhost conf file to proxy requests from https://public-url.local/go/{{short-link}} to https://short-url.local.

<VirtualHost public-url.local:443>
    DocumentRoot "C:/sites/public-url.local"
    ServerName public-url.local
    SSLEngine on
    SSLCertificateFile conf/ssl.crt/server.crt
    SSLCertificateKeyFile conf/ssl.key/server.key
    ErrorLog "logs/error_log.log"
    CustomLog "logs/access_log.log" common
    SSLProxyEngine on
    ProxyPass /go http://short-url.local
    ProxyPassReverse /go http://short-url.local
    RewriteMap lowercase int:tolower
    <Directory "C:/sites/public-url.local">
        Require all granted

What I am finding though is generated urls still use defined constant YOURLS_SITE

define( 'YOURLS_SITE', 'http://short-site.local' );

Is there a way tell either the yourls admin panel (and the api) to output the list of shortlinks to using the proxied public-url.local domain?


Hello @onebitrocket

Did you try the following?

define( 'YOURLS_SITE', 'https://public-url.local/go' );

Hi @LeoColomb,

I thought that constant was also used by the admin panel?

define( 'YOURLS_SITE', 'https://public-url.local/go' );

Meaning http://short-url.local/admin would not resolve

Is that not correct?


Actually it depends on how your proxy behaves. Admin pages may be accessible at https://public-url.local/go/admin too.

The YOURLS_SITE constant is mainly used to print short URLs on the admin pages, but does not constrain YOURLS behavior, i.e. if YOURLS_SITE == 'http://short-site.local', https://public-url.local/go/keyword should also work.