.htaccess - nginX 中的 URL 重写

标签 .htaccess url url-rewriting nginx seo

我们目前运行 Apache 并使用 .htaccess 在包括 WordPress 和 OpenCart 在内的多个脚本中重写 URL。

出于性能原因,我们想转移到 nginX+Varnish 堆栈。我们如何在 nginX 中处理 URL 重写,我们能否自动化它,就像 WordPress 和 OpenCart 写入(写入).htaccess 的方式

最佳答案

location ^~ /location {
  # some code else rewrite
  rewrite ^/your_rules # Or
  try_files $uri @rewrite_loc;
}

location @rewrite_loc {
  # some code
  # I guess you are not talking about proxy_pass
}

是的,你可以像使用 Apache.htaccess 一样使用 Nginx,只需要定义好的重写规则。

关于.htaccess - nginX 中的 URL 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15624874/

相关文章:

javascript - 对 JavaScript 文件强制进行 GZIP 压缩

.htaccess - htaccess 和 URL 重写

java - Spring Boot 中的 @PathVariable 在 URL 中带有斜杠

java - trimFilter和UrlRewriteFilter导致IllegalStateException

c# - 如何将查询字符串重写为 asp.net 中的域?

regex - 尝试在同一个端口设置域和子域。 (NGINX)

php - PHP 中的自定义 404 错误页面

spring - 使用 @RequestMapping 匹配 URL 模式

javascript - 手动刷新或写入时,React-router网址不起作用

node.js - .htaccess 路由到 Node App