帮助将Apache htaccess转换为Nginx重写规则
我需要将以下Apache htaccess规则转换为Nginx重写规则: 重定向301/feed.php帮助将Apache htaccess转换为Nginx重写规则,apache,.htaccess,nginx,rewrite,Apache,.htaccess,Nginx,Rewrite,我需要将以下Apache htaccess规则转换为Nginx重写规则: 重定向301/feed.php 非常感谢~格式有点不合适,但我想你原来的规则是 Redirect 301 /feed.php http://www.example.com/feed/ 因此,Nginx重写将是 rewrite ^/feed\.php http://www.example.com/feed/ permanent; 如果你喜欢,这并不难。格式有点不合适,但我想你原来的规则是 Redirect 301 /fe
非常感谢~格式有点不合适,但我想你原来的规则是
Redirect 301 /feed.php http://www.example.com/feed/
因此,Nginx重写将是
rewrite ^/feed\.php http://www.example.com/feed/ permanent;
如果你喜欢,这并不难。格式有点不合适,但我想你原来的规则是
Redirect 301 /feed.php http://www.example.com/feed/
因此,Nginx重写将是
rewrite ^/feed\.php http://www.example.com/feed/ permanent;
如果您使用以下bash-one-liner来转换.htaccess文件中的Apache重定向行,这并不困难:
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
。。。行打印为以下Nginx样式:
location /feed.php {
return 301 http://www.example.com/feed/;
}
使用以下bash one liner转换.htaccess文件中的Apache重定向行:
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
。。。行打印为以下Nginx样式:
location /feed.php {
return 301 http://www.example.com/feed/;
}