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/; 
}