python-IIS7.5-web.config-rewrite规则转.htaccess.py- """
- python-IIS7.5-web.config-rewrite规则转.htaccess.py
- 2016年3月8日 12:02:31 codegay
- """
- import re
-
- with open("Web.config",encoding="utf-8") as f:
- txt=f.read()
-
- with open(".htaccess","w+") as f:
- ref=re.findall(r"""<rule name.+?match url="(.+?)".+?url="(.+?)".+?</rule>""",txt,16)
- results=["RewriteRule "+r[0]+"$ "+r[1].replace("{R:1}","$1").replace("{R:2}","$2")+" [L]\n" for r in ref]
- print(results)
- f.writelines(results)
- #2016年3月8日 12:39:52
复制代码
|