我已经设法转换了大部分,但我在这两个方面有点挣扎 – RewriteRule ^(.+)/$http://%{HTTP_HOST}/$1 [R=301,QSA,L]RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$index.php如果有...

我已经设法转换了大部分,但我在这两个方面有点挣扎 –
RewriteRule ^(.+)/$http://%{HTTP_HOST}/$1 [R=301,QSA,L]
RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$index.php
如果有人是一个nginx重写忍者会很感激的手:)
解决方法:
这个:
RewriteRule ^(.+)/$http://%{HTTP_HOST}/$1 [R=301,QSA,L]
将被转换为:
rewrite ^/(.+)/$http://$http_host/$1 permanent;
还有这个:
RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$index.php
将被转换为:
rewrite /!^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$/index.php;
你也可以用:
if ($rule_0 = ""){
rewrite ^/(.+)/$http://$http_host/$1 permanent;
}
if ($rule_0 = ""){
rewrite /!^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$/index.php;
}
文档:http://wiki.nginx.org/HttpRewriteModule
来自:http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
织梦狗教程
本文标题为:需要帮助将Apache2重写规则转换为nginx


基础教程推荐
猜你喜欢
- RFO SIG之openEuler AWS AMI 制作详解 2022-12-28
- Apache Kafka 2.5 稳定版发布,新特性抢先看 2023-09-11
- 为Win2003服务器打造铜墙铁壁的方法步骤 2022-09-01
- windows环境下apache-apollo服务器搭建 2023-09-10
- P3 利用Vulnhub复现漏洞 - Apache SSI 远程命令执行漏洞 2023-09-10
- Centos7 nginx的安装以及开机自启动的设置 2023-09-22
- Centos 安装Django2.1 2023-09-24
- 通过StatefulSet部署有状态服务应用实现方式 2022-10-01
- Docker容器操作方法详解 2022-11-13
- Apache CarbonData 1.0.0发布及其新特性介绍 2023-09-11