0

I want everytime people go to my website, it will automatically redirect to another website, say:

https://www.redirect.com/link?q=NEWSTRING

it sounds weird, but actually, what I want is when people load my page, it will trigger some scripts, in which it can tract "NEWSTRING" from some website, then put it to the link above to redirect my website there. So what I have is a first part of the link, which is fixed:

https://www.redirect.com/link?q=

then

NEWSTRING 

is obtained from my script, now how to write some thing that will redirect the webpage? What I can think of is, write something in python.py, then rename it to .cgi, then upload it to my server at :

/home/xxxxx/public_html/cgi-bin/python.cgi

Will this make my website automatically load and redirect there ? Thanks a lot !

user1314404
  • 1,253
  • 3
  • 22
  • 51

2 Answers2

1

Why not just use straight HTML to redirect to the website you want? I might not understand your question correctly, but for example

<meta http-equiv="refresh" content="0; url=http://example.com/">

would redirect the user to http://example.com when loading your page.

Serban Constantin
  • 3,316
  • 1
  • 18
  • 20
  • can I put python script together with it ? Coz I need to extract some info from another web to put it to this link. Like this :http://stackoverflow.com/questions/16829066/extract-text-from-website-source-code; can it be done easier by html and javascript ? – user1314404 May 30 '13 at 11:33
0

What you need is an AJAX request.

When people load your web page, the page sends an AJAX request to some other site, and render your page after getting the request result.

  • can we use that in middle of python code ? Coz I get the NEWSTRING using python – user1314404 May 30 '13 at 07:02
  • the AJAX request is sent in javascript via GET/POST method to a server, in your case, where your Python script runs. So write a handler for this AJAX request which returns data to the javascript. –  May 30 '13 at 07:07
  • are they coded in the same file (like inded.html) or what kind of link between them ? Can you give an example pls ! – user1314404 May 30 '13 at 07:17
  • Have you successfully run your python script on some server? –  May 30 '13 at 08:40
  • It is the first time I think of using it on the server. But I think people must use it very often outthere – user1314404 May 30 '13 at 10:49
  • So first of all get your script running on the server. Take a look at this: http://code.activestate.com/recipes/365606/ –  May 31 '13 at 01:31