我已经设法转换了大部分,但我在这两个方面有点挣扎 – 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
猜你喜欢
- CentOS7安装GlusterFS集群的全过程 2022-10-10
- 解决:apache24 安装后闪退和配置端口映射和连接超时设置 2023-09-11
- 教你在docker 中搭建 PHP8 + Apache 环境的过程 2022-10-06
- nginx中封禁ip和允许内网ip访问的实现示例 2022-09-23
- 【转载】CentOS安装Tomcat 2023-09-24
- 阿里云ECS排查CPU数据分析 2022-10-06
- CentOS_mini下安装docker 之 安装docker CE 2023-09-23
- KVM虚拟化Linux Bridge环境部署的方法步骤 2023-07-11
- IIS搭建ftp服务器的详细教程 2022-11-15
- 利用Docker 运行 python 简单程序 2022-10-16
