ToBulk
ToBulk

Reputation: 1

WordPress and YOURLS on one domain (Nginx)

I want to run both WordPress and YOURLS on one domain.

Since both need to handle URLs differently, they need different try_files directives. WordPress sits on the root of the domain (domain.tld), while YOURLS is being installed to the /go/ directory.

Despite the two location rules, I get 404s on any links generated by YOURLS (e.g. domain.tld/g/linkname, all are redirects to external URLs), though I can access the YOURLS admin backend.

As far as I read, declaring to location rules (one for /go/, and one for /) should suffice in order to let Nginx handle the direct and the /go/ URLS differently - is there something in wrong in my thinking?

I have added the following to the Nginx config:

location / {
try_files  $uri $uri/ /index.php?$args;
}

location /go/ {
try_files $uri $uri/ /go/yourls-loader.php$is_args$args;
}

What am I missing?

Upvotes: 0

Views: 344

Answers (1)

user13229327
user13229327

Reputation: 1

Not sure if it will be of direct help to you or not. I was trying to do a similar configuration using a subdirectory pointing to yourls docker After many hits and trials, the following settings have worked for me. Maybe some part of it might be useful for someone.

location ~ (\/shorturl\/.*) {
    if ( $uri ~ ^\/shorturl\/((admin|images|js|css)(\/?)(.*)|.*.(\.html|\.php)) ) {
            rewrite /shorturl(/?)(.*) $1$2 break;
    }
    rewrite (\/shorturl\/.*) $1 break;
    proxy_pass http://localhost:9091;
    proxy_redirect / /shorturl/;
}

PS: I know if is evil and please add proxy headers as per your need!

Upvotes: 0

Related Questions