【发布时间】:2011-04-16 03:08:44
【问题描述】:
【问题讨论】:
标签: apache .htaccess nginx rewrite
【问题讨论】:
标签: apache .htaccess nginx rewrite
格式有点不对,但我认为您的原始规则是
Redirect 301 /feed.php http://www.example.com/feed/
所以 Nginx 重写将是
rewrite ^/feed\.php http://www.example.com/feed/ permanent;
如果你read the documentation,不难。
【讨论】:
使用以下 bash 单行代码来转换 .htaccess 文件中的 Apache Redirect 行:
while read LINE; do echo -e `echo $LINE | egrep '^Redirect' | cut -d' ' -f1-2` "{\n\treturn 301 `echo $LINE|cut -d' ' -f3`;\n}"; done < .htaccess
结果,
Redirect /feed.php http://www.example.com/feed/
... 行打印为以下 Nginx 样式:
location /feed.php {
return 301 http://www.example.com/feed/;
}
【讨论】: