我需要convertthe以下的Apache的htaccess规则Nginx的重写规则:帮助转换的Apache的htaccess到Nginx的重写规则
重定向301 /feed.php http://www.example.com/feed/
非常感谢〜
我需要convertthe以下的Apache的htaccess规则Nginx的重写规则:帮助转换的Apache的htaccess到Nginx的重写规则
重定向301 /feed.php http://www.example.com/feed/
非常感谢〜
格式的有点偏离,但我假设你原来的规则是
Redirect 301 /feed.php http://www.example.com/feed/
所以Nginx重写将
rewrite ^/feed\.php http://www.example.com/feed/ permanent;
不难,如果你read the documentation。
使用以下的bash一行程序,转换的Apache重定向行.htaccess文件:
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/;
}