Results 1 to 4 of 4
hi all
how can i redirect an url to othe
i foung this code by googling
Code:
#!/usr/bin/perl
# Perl script redirect to another http/ftp url or a page
# ...
- 04-12-2007 #1Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
pearl redirection
hi all
how can i redirect an url to othe
i foung this code by googling
is this the way to redirect?Code:#!/usr/bin/perl # Perl script redirect to another http/ftp url or a page # You can call perl script as follows: # # A) Redirect to url cyberciti.biz # http://mydomain.com/cgi-bin/rd?url=http://cyberciti.biz/ # # B) To call perl script from html page as javascript # (put in your html file, note o=js option at the END): # <script language="JavaScript" type="text/javascript" # src="http://mydomain.com/cgi-bin/rd.pl?url=http://cyberciti.biz/&o=js" # </script> # ----------------------------------------------- # Copyright (c) 2005 Vivek G Gite <http://cyberciti.biz/fb/> # This perl script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------ use strict; use warnings; use CGI; # new CGI my $q = CGI->new( ); my $error; # get url param my $rdurl = $q->param("url"); # output can be # js - for javascript, to create javascript based redirection so you can use script from HTML pages # make sure o param is in lowercase :) my $output = lc($q->param("o")); # make sure url passed as url=http://somewhere.com/page.html if ( $q->param('url') eq "" ){ print $q->header(); print $q->start_html(-title=>"Error URL missing"); $error = "URL missing, you must run this script http://" . $ENV{'SERVER_NAME'} . $ENV{'SCRIPT_NAME'} ; $error .= "?url=http://abc.com/somepage.html<BR>"; $error .= "I will redirect a page/url to http://abc.com/somepage.html"; print $error; print $q->end_html(); } else{ # redirect to a page if ( $output eq "" || $output eq "html" ){ print $q->redirect( -URL => $rdurl); } else { # do javascript based redirection / a page # Send fresh header or sky will fall on you :P print $q->header(); # do a page redirection with javascript print "window.location=\"$rdurl\";\n\n"; } }
i am usinf Fedora5.
i would like to know this concept.
can you please help me
thank you in advance
- 04-12-2007 #2
- 04-13-2007 #3Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
thank you for quick replay
hi
Originally Posted by likwid
i would like to redirect an url to other.
is there any process with pearl or bash or ruby or c language
if yes please help me.
thank you in advance
- 04-13-2007 #4
That's what this script does... I don't understand what the advantage of using this instead of a Redirect directive in apache is, but I am not the master of web apps or anything.


Reply With Quote