Created
March 8, 2016 08:22
-
-
Save FGFW/776a275ef977074acf9b to your computer and use it in GitHub Desktop.
python-IIS7.5-web.config-rewrite规则转.htaccess.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment