我们目前运行 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/