wordpress - NGINX 尾部斜杠但不包括 wp-json 和 wp-admin

标签 wordpress nginx

我正在使用这个 NGINX 规则来强制 WordPress 网站的尾部斜杠:

rewrite ^([^.]*[^/])$ $1/ permanent;

但是这个规则给 Gutenberg 和 wp-json 带来了一些麻烦。

除了/wp-json/* 和/wp-admin/* 之外,我如何对所有内容使用上面的规则?

最佳答案

尝试否定正则表达式前瞻:

rewrite ^(?!/wp-admin|/wp-json)([^.]*[^/])$ $1/ permanent;

参见 this解释文章。

关于wordpress - NGINX 尾部斜杠但不包括 wp-json 和 wp-admin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62341451/

相关文章:

css - 尽管文件路径正确,但附加 css 文件时出现 404 错误。

Nginx 尝试下载文件而不是显示

nginx - 在不同端口上使用 nginx 的 Http 基本身份验证

jquery - 错误: Option 'ajax' is not allowed for Select2 when attached to a <select> element woocommerce

css - 菜单对齐- wordpress

php - 不同尺寸的 Wordpress 特色图片

wordpress - WordPress 中的 get_the_* 和 the_* 模板标签有什么区别?

nginx - 使用 proxy_pass 配置 Nginx 的两个位置

caching - 如何仅在 NGINX 中的 index.html 页面上设置不缓存

ssl - 400 错误请求 : The SSL certificate error