I have wordpress working well in mysite.com but YOURLS which is installed in mysite.com/u is not working, when I click on any shortened link I get a 404 error (wordpress).
However, I get YOURLS to work by adding this to nginx.conf
location /u { try_files $uri $uri/ /u/yourls-loader.php;
But then WordPress links break.
Here is my default nginx.conf
I know the fix is to add this try_files $uri $uri/ /u/yourls-loader.php;
somewhere in nginx.conf , but where to put it without breaking wordpress.?
=================== Update 1 =========================
I got this partially working. with same config, but I noticed that wordpress links that start with u
doesn't work ex: http://example.com/understand-math
instead it redirect to Error 403 - Forbidden
???
================ update 2 ============
ok I fixed it by just adding another slash /
to location /u/
instead of location /u
YOURLs NGINX CONFIGURATION
server {
# Listen IPv4 & v6
listen 80;
listen [::]:80;
# Optional SSL stuff
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate example.com.crt;
ssl_certificate_key example.com.key;
# Server names
server_name example.com www.example.com;
# Root directory (NEEDS CONFIGURATION)
root /path/to/files;
# Rewrites
location / {
# Try files, then folders, then yourls-loader.php
# --- The most important line ---
try_files $uri $uri/ /yourls-loader.php;
# PHP engine
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock; # Can be different
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}