apache - Apache 到 NGINX 重写问题
问题描述
我正在尝试将此 apache 转换ReWriteRule
为 NGINX,但它似乎不起作用。
阿帕奇规则:RewriteRule ^([A-Za-z0-9_-]+)\.php$ index.php?pagename=$1 [NC,QSA]
NGINX(不工作):location / { rewrite ^/([A-Za-Z0-9_-]+)\.php? /index.php?pagename=$1; }
我确实在位置块中有 NGINX 规则。
我在这里想念什么?我查看了其他类似的问题,但没有找到足够的合适线索来解决问题。谢谢您的帮助。
解决方案
使用转换器:
server {
server_name example.com;
rewrite ^/([A-Za-z0-9_-]+)\.php$ /index.php?pagename=$1;
}
事实上,许多重写更容易,只需rewrite
放置在server {}
上下文中(不需要多余的location
)。
推荐阅读
- r - R中具有3个参数(4d)的绘图函数
- apache-spark - Spark中的RDD和Dataframe有什么区别?
- python - 无法在 Flask 中获取 ImmutableMltiDict 中的所有元素
- python - 如何将列表中的所有项目一一删除并在删除后同时打印
- c++ - 折叠表达式、参数包扩展、类成员函数中的递归
- javascript - 检查map中是否存在key
- java - 回滚多个服务
- crystal-reports - 如何在水晶报表中使用公式显示和隐藏 LineObject?
- c# - HttpClient - 任务被取消
- tomcat - Intellij-IDEA 可以在 tomcat 中启动和调试 jersey 应用程序,但是将战争部署到 tomcat 得到 404