0

我的 wordpress 在 mysite.com 中运行良好,但安装在 mysite.com/u 中的YOURLS无法正常工作,当我单击任何缩短的链接时,我会收到 404 错误(wordpress)。

但是,我通过将其添加到 nginx.conf 来让你的工作

location /u { try_files $uri $uri/ /u/yourls-loader.php;

但随后 WordPress 链接中断。

这是我的默认nginx.conf 我知道解决方法是将其添加 try_files $uri $uri/ /u/yourls-loader.php;到 nginx.conf 中的某个位置,但是在不破坏 wordpress 的情况下将其放在哪里。?

=================== 更新1 =========================

我得到了这部分工作。使用相同的配置,但我注意到以开头的 wordpress 链接u不起作用 ex:http://example.com/understand-math而是重定向到Error 403 - Forbidden

???

================ 更新2 ============

好的,我通过添加另一个斜杠/location /u/不是location /u

4

1 回答 1

0

你的 NGINX 配置

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;
    }
  }
}

GitHub 文档

于 2015-01-12T17:14:05.307 回答