CGI重定向到另一个页面 [英] CGI Redirect to another page

查看:397
本文介绍了CGI重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CGI下运行的Python脚本中,我可以以编程方式将

程序重定向到另一个页面。假设我有一个我想要的静态HTML页面显示
(例如index.htm)。除了''print ...''有没有办法将
重定向到这个URL(例如,像ASP中的Response.Redirect())?


非常感谢。

In a Python script running under CGI, can I programatically redirect the
program to another page. Assume that I have a static HTML page that I want
displayed (e.g. index.htm). Other than ''print ...'' is there any way to
redirect to this URL (for example, like Response.Redirect() in ASP)?

Many thanks.

推荐答案

Andrew Chalk:
Andrew Chalk:
假设我有一个我想要的静态HTML页面
显示(例如index.htm)。除了''print ...''有没有办法重定向到这个URL(例如,像ASP中的Response.Redirect())?
Assume that I have a static HTML page that I want
displayed (e.g. index.htm). Other than ''print ...'' is there any way to
redirect to this URL (for example, like Response.Redirect() in ASP)?




Response.Redirect可能通过在标题中放入

来实现。您拥有的HTML页面无法访问标题。但是,您可以使用元标记告诉

浏览器查找其他位置。但这对于那些没有解析HTML的工具来说不行。


这是一个简单的网络搜索(一旦你知道了)正确的关键字:) -

" header redirect meta"我找到了
http://vancouver-webpages.com /META/FAQ.html#redirect

如何将用户重定向到另一个页面?

有三个不同的答案


Andrew
da***@dalkescientific.com



The Response.Redirect likely works by putting something in
the header. The HTML page you have doesn''t have access to
the header. However, you can use the meta tag to tell the
browser to look elsewhere. But that won''t work for tools which
don''t parse the HTML.

It''s an easy web search (once you know the right keywords :) -
"header redirect meta" and I found
http://vancouver-webpages.com/META/FAQ.html#redirect
"How can I redirect the user to another page ?"
with three different answers

Andrew
da***@dalkescientific.com


在消息< NW ********************* @newssvr11.news.prodigy.co m>

" Andrew Chalk" <交流**** @ XXXmagnacartasoftware.com>写道:
In message <NW*********************@newssvr11.news.prodigy.co m>
"Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote:
在CGI下运行的Python脚本中,我可以编程方式将
程序重定向到另一个页面。


你的意思是重定向客户端浏览器吗?

假设我有一个我想要显示的静态HTML页面(例如
index.htm) 。除了''print ...''有没有办法重定向到这个
URL(例如,像ASP中的Response.Redirect())?
In a Python script running under CGI, can I programatically redirect the
program to another page.
Do you mean redirect the client browser ?
Assume that I have a static HTML page that I want displayed (e.g.
index.htm). Other than ''print ...'' is there any way to redirect to this
URL (for example, like Response.Redirect() in ASP)?




假设您打算不打印整页,当您说除了

''打印...''然后;


打印"位置:http:abcxyz.index.html"


AFAIUI它只是发送一个重定向标题。


-

___

| im ---- ARM Powered ----



Assuming you mean not to print the whole page, when you say "Other than
''print ...''" then;

print "Location: http:abcxyz.index.html"

AFAIUI it simply sends a redirect header.

--
___
|im ---- ARM Powered ----


在消息< 09 ************ @ worthy.demon.co.uk>

Tim Howarth< ti*@worthy.demon。 co.uk>写道:
In message <09************@worthy.demon.co.uk>
Tim Howarth <ti*@worthy.demon.co.uk> wrote:
在消息< NW ********************* @newssvr11.news.prodigy.co m>
Andrew Chalk <交流**** @ XXXmagnacartasoftware.com>写道:
In message <NW*********************@newssvr11.news.prodigy.co m>
"Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote:
在CGI下运行的Python脚本中,我可以编程方式将
程序重定向到另一页。
In a Python script running under CGI, can I programatically redirect the
program to another page.



print" ;位置:http:abcxyz.index.html"



print "Location: http:abcxyz.index.html"




甚至是正确形成的网址!


-

___

| im ---- ARM Powered ----



Or even a properly formed URL !

--
___
|im ---- ARM Powered ----


这篇关于CGI重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆