2010-09-23 108 views

回答

3

格式的有点偏离,但我假设你原来的规则是

Redirect 301 /feed.php http://www.example.com/feed/ 

所以Nginx重写将

rewrite ^/feed\.php http://www.example.com/feed/ permanent; 

不难,如果你read the documentation

1

使用以下的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/; 
}