我正在尝试编写一个python cgi脚本,它会将我重定向到打印出其中一个传入参数的页面。
重写规则如下所示:RewriteRule ^(.*)$ /cgi-bin/redirect.py?url=%{HTTP_HOST}$1 [L,QSA,PT].
基本上我想要做的就是打印<h1></h1>
标签之间的参数URL。我之前从未写过cgi脚本,因此我们非常感谢任何建议。
答案 0 :(得分:0)
Hello World
类帐户有lots of resources on the internet个版本。或者您可以使用standard documentation获取答案。
答案 1 :(得分:0)
我不知道“[L,QSA,PT]”的作用,但我会做^(.*)$ /cgi-bin/redirect.py
redirect.py应该类似于:
#!/usr/bin/env python
print """Content-type: text/html
<html><head><title>Redirect</title></head><body>
<h1>%s/%s</h1></body></html>"""%(os.environ['HTTP_HOST'], os.environ['REQUEST_URI'])
我没有测试过,所以我可能完全错了: - )