Board logo

标题: [原创代码] python-IIS7.5-web.config-rewrite规则转.htaccess.py [打印本页]

作者: codegay    时间: 2016-3-8 16:22     标题: python-IIS7.5-web.config-rewrite规则转.htaccess.py

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





欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2