【问题标题】:Yourls Errors in WordPressWordPress中的Yourls错误
【发布时间】:2015-03-09 19:20:47
【问题描述】:

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

但是,通过将其添加到 nginx.conf 中,我得到 YOURLS 的工作

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

但随后 WordPress 链接中断。

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

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

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

???

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

好的,我通过在location /u/ 上添加另一个斜杠/ 而不是location /u 来修复它

【问题讨论】:

  • 你试过这个设置/wp-admin/options-permalink.php吗?
  • @Rafael ,问题出在 nginx 配置中。 wordpress 运行良好,没有问题。唯一的问题是在不破坏 wordpress 的情况下将这个 location /yourls { try_files $uri $uri/ /yourls/yourls-loader.php; 放在哪里,我已经为任何愿意提供帮助的人提供了我的 nginx 配置。

标签: wordpress mod-rewrite nginx yourls


【解决方案1】:

YOURLs 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 DOCUMENTATION

【讨论】:

  • 那是 /yourls 安装在根目录中,但我将 yourls 安装在子目录中,并将 wordpress 安装在根目录中,我不知道如何使它们同时工作。当我修复你的问题,我会破坏 wordpress,反之亦然。
  • 我编辑了配置文件并选择它作为接受的答案,谢谢:)
猜你喜欢
  • 2021-05-06
  • 2016-07-13
  • 2015-01-23
  • 2013-02-20
  • 2021-04-03
  • 2015-06-23
  • 1970-01-01
  • 1970-01-01
  • 2012-06-10
相关资源
最近更新 更多