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. 12 30262
Andrew Chalk: 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)?
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
In message <NW*********************@newssvr11.news.prodigy.co m>
"Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote: 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)?
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 ----
In message <09************@worthy.demon.co.uk>
Tim Howarth <ti*@worthy.demon.co.uk> wrote: In message <NW*********************@newssvr11.news.prodigy.co m> "Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote:
In a Python script running under CGI, can I programatically redirect the program to another page.
print "Location: http:abcxyz.index.html"
Or even a properly formed URL !
--
___
|im ---- ARM Powered ----
Thanks, good web search! I couldn't get "Location:URL" to work but META did.
Regards.
"Andrew Dalke" <ad****@mindspring.com> wrote in message
news:4n****************@newsread4.news.pas.earthli nk.net... Andrew Chalk: 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)?
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
Tim Howarth <ti*@worthy.demon.co.uk> wrote: print "Location: http://abcxyz/index.html"
AFAIUI it simply sends a redirect header.
Yep; however, if you include a relative URI with no hashpart:
print 'Location: /index.html'
print
Then the server should send that page to the browser directly, without
sending a redirect back to the browser. This may be preferable in
some cases.
(The second print is needed to end the CGI response headers.)
Full spec here: http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
(Using JavaScript or meta-refresh to do redirects is almost always a
really terrible idea.)
--
Andrew Clover
mailto:an*@doxdesk.com http://www.doxdesk.com/
Tim Howarth <ti*@worthy.demon.co.uk> wrote: print "Location: http://abcxyz/index.html"
AFAIUI it simply sends a redirect header.
Yep; however, if you include a relative URI with no hashpart:
print 'Location: /index.html'
print
Then the server should send that page to the browser directly, without
sending a redirect back to the browser. This may be preferable in
some cases.
(The second print is needed to end the CGI response headers.)
Full spec here: http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
(Using JavaScript or meta-refresh to do redirects is almost always a
really terrible idea.)
--
Andrew Clover
mailto:an*@doxdesk.com http://www.doxdesk.com/
On Wed, 24 Sep 2003, Andrew Chalk wrote: 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)?
you have two options:
- write a Location header; the web server will notice it and spit out the
file you specify
- write Status and Location headers, giving status 302 (or 303); the web
server will notice the Status header and give the client the appropriate
status code; the client will then follow the redirect you give it in the
Location header
see: http://hoohoo.ncsa.uiuc.edu/cgi/out.html http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
tom
--
One chants out between two worlds Fire - Walk With Me. an********@doxdesk.com (Andrew Clover) writes:
[...]> (Using JavaScript or meta-refresh to do redirects is almost always a really terrible idea.)
I know I don't like them "on principle", but what practical problems
do they cause? Do proper HTTP redirects avoid the "back button trap",
maybe? I've never noticed...
John
What is wrong with meta-refresh?
"Andrew Clover" <an********@doxdesk.com> wrote in message
news:2c**************************@posting.google.c om... Tim Howarth <ti*@worthy.demon.co.uk> wrote:
print "Location: http://abcxyz/index.html"
AFAIUI it simply sends a redirect header.
Yep; however, if you include a relative URI with no hashpart:
print 'Location: /index.html' print
Then the server should send that page to the browser directly, without sending a redirect back to the browser. This may be preferable in some cases.
(The second print is needed to end the CGI response headers.)
Full spec here:
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
(Using JavaScript or meta-refresh to do redirects is almost always a really terrible idea.)
-- Andrew Clover mailto:an*@doxdesk.com http://www.doxdesk.com/
Andrew Chalk wrote: What is wrong with meta-refresh?
The use of the Location header is much more direct.
--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ An undevout astronomer is mad.
\__/ Edward Young
[Andrew Chalk wrote] What is wrong with meta-refresh?
It is claimed that search engines treat meta-refresh with suspicion. I
don't know if this is true or not. The following article (as an
example, this is just the first link I found when googling for "abuse
meta refresh"), claims that Altavista bans sites that use a meta
refresh period below 30 seconds.
META Refresh And Search Engines http://www.netmechanic.com/news/vol4/promo_no15.htm
regards,
--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan
John J. Lee <jj*@pobox.com> wrote: I know I don't like them "on principle", but what practical problems do they cause? Do proper HTTP redirects avoid the "back button trap", maybe?
Yes, they do. They are also more widely supported by robots (including
search engine spiders) and older and non-desktop browsers (as well as
newer browsers which can have meta-refresh and/or JavaScript disabled).
An HTTP redirect is an unequivocal statement that a resource is elsewhere,
at a transport level. It can be understood and acted on by agents with no
knowledge of HTML or JavaScript (for example Python's urllib), and can
potentially be used to automatically update links.
Meta-refresh (or, less commonly used, Refresh as an HTTP header) was
designed for re-fetching pages that update themselves, such as webcams.
It's still useful for this, although it has yet to be standardised.
Using meta-refresh or JavaScript for a redirect is really a misuse,
and is needed only:
a. When you need to set a cookie at the same time as doing a redirect.
Some browsers will not allow a cookie to be set in anything but a
'200 OK' response.
b. When your web hosts are exceedingly crappy and don't allow you to
do proper redirects through server config or CGI.
In these cases I prefer to use JavaScript's location.replace() method (which
also avoids the back button trap), combined with a short-delay meta-refresh
as backup and a plain HTML link in the returned page as backup for the
backup (for robots etc).
Alan Kennedy <al****@hotmail.com> wrote:
It is claimed that search engines treat meta-refresh with suspicion. I don't know if this is true or not.
It's not easy to tell, but Google is known to have 'anti-cloaking' measures
for detecting search engine abuse. Since meta-refresh is commonly used for
sending browsers to a different page than engines, it is possible that
a meta-refresh - likely combined with other indicators Google could find
suspicious - might result in a PR0 block.
More importantly, many robots won't follow a meta-refresh at all. (After all,
they don't want to end up following an infinitely refreshing webcam page.)
So a backup <a> link should always be included.
--
Andrew Clover
mailto:an*@doxdesk.com http://www.doxdesk.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul |
last post by:
I'm not getting the results I want when I use
Response.Redirct in a ASP page.
I enter this line of code in a asp page from domain1.com.
Response.Redirect...
|
by: T Conti |
last post by:
Howdy:
I have converted a huge ASP page over to .Net (C#). The old page has
been will be removed from our site, but I need to have a dummy page
there that will redirect the user to the new site...
|
by: Victor |
last post by:
I need to redirect to another web page, but that redirect will include the
submission of form data. So, unlike ServerXMLHTTP which stays on the
originating web page, I need the script to redirect...
|
by: Pooja Renukdas |
last post by:
Hello,
I have this web site where only two pages have to be secure pages and
I need to call them using https, but since I have my development
server and my production web server, I dont want to...
|
by: Mantorok |
last post by:
Hi all
When I start a new thread that tries to call:
HttpContext.Current.Response.Redirect()
It fails as Current returns null, is there anyway to access the current
httpcontext from within...
|
by: David |
last post by:
I need to redirect to a page and HTTP Post data. The
Response.Redirect does not work and the HTTPREQUEST option calls the
page and waits for a response, but I need to transfer control to the...
|
by: Coleen |
last post by:
Hi all :-)
I need to redirect to multiple pages on click of a transmit button, without
redisplaying each page. This redirection is to capture session variables
that are created on each page and...
|
by: rouellette |
last post by:
Is it possible to redirect to another page in your application from the start page BEFORE the user has been authenticated if you're using FORMS authentication? I can't seem to get it to work.
...
|
by: =?Utf-8?B?SlA=?= |
last post by:
All the sudden my app has started to loose Session values after a
Response.Redirect to another page in the same project. Ive read several post
about setting the Terminate Boolean to false to solve...
|
by: UKuser |
last post by:
Hi,
I'm not sure if this can be done as I've searched the web and this
forum.
I am using an online merchant provider and I must post certain
variables to their webforms through a form on my...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| |