Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  156] [ 3]  / answers: 1 / hits: 18606  / 13 Years ago, mon, august 29, 2011, 12:00:00

I am looking for fast methods/ways I can redirect a HTML page to another page.



Currently I use meta-tags to redirect a HTML page to a python script that grabs the website HTML from a SQL database(grabs different HTML based on whether user is on a Mobile device) then sends that HTML back. But this is visibly slow, it shows a blank white page(redirect HTML page) then shows the python script page.



I know that its not the python script thats slow because if I just go straight to the python script(no redirect from the HTML page) then it loads very fast & with no white screen.



So for example; someone accesses http://mywebsite.com/contactUs.html which contains only the following HTML:



<HTML> <HEAD><META HTTP-EQUIV=Refresh CONTENT=0; url=cgi-bin/loadWebPage.py?webpage=50002>  </HEAD> </HTML> 
<!-- This redirects to my python script that grabs the contact us HTML & prints it out(shows the webpage HTML) -->


Are there other ways a HTML file can redirect to a python script that will be faster?



Maybe I can use HTTP messages? Would the following text/code work in a HTML file?:



Status: 301 Moved
Location:/cgi-bin/loadWebPage.py?webpage=50002


Would my last resort be AJAX or javascript to get the fastest result?



<html>
<head>

<script type=text/javascript>
<!--
window.location = 'http://mywebsite.com/cgi-bin/loadWebpage.py?webPage=50001';
-->
</script>
</head>
<body>

</body>
</html>

More From » html

 Answers
4

Place a file called .htaccess in the same directory as your HTML file. If the file is called http://www.example.com/foo/bar.html then .htaccess would contain:



Redirect permanent /foo/bar.html http://www.example.com/script.py



Note that the file that gets redirected does not have http://www.example.com, while the file you redirect it to needs the full URL.



If it's your own server, it's a little faster to disable .htaccess files, while instead putting the Redirect command in your httpd.conf file.


[#90376] Friday, August 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kalias

Total Points: 79
Total Questions: 116
Total Answers: 116

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
;