容器技术交流

 找回密码
 立即注册
查看: 3113|回复: 3

Apache Rewrite规则如何换成Nginx写法

[复制链接]
发表于 2014-3-16 18:26:06 | 显示全部楼层 |阅读模式
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php [L]

#RewriteCond %{HTTP_HOST} ^xxxx.net [NC]
#RewriteRule ^(.*)$ http://www.xxxx.net/$1 [R=301,NC,L]

</IfModule>

我是域名指定子目录。没法用Apache 实现伪静态,只能换成Nginx 望高手指点

 楼主| 发表于 2014-3-16 18:37:50 | 显示全部楼层
找到一个自动转换的地方
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

换成是这样子
if (!-f $request_filename){
        set $rule_0 1$rule_0;
}
#ignored: condition 1
if ($rule_0 = "2"){
        rewrite /. /index.php last;
}
if ($http_host ~* "^xxxx.com"){
        set $rule_1 1$rule_1;
}
if ($rule_1 = "1"){
        rewrite ^/(.*)$ http://www.xxxx.com/$1 permanent;
}
放到location里提交,提示“表单令牌错误”
 楼主| 发表于 2014-3-16 19:31:46 | 显示全部楼层
似乎没什么人逛。我再顶一下
发表于 2015-3-11 11:54:04 | 显示全部楼层
找不到解决方法··
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|URLOS ( 粤ICP备18087780号 )

GMT+8, 2024-4-20 15:04 , Processed in 0.047378 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表