Home > Archive > PERL CGI Beginners > May 2004 > Re: Redirect using .htaccess or ?? ( kinda [OT] )
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Redirect using .htaccess or ?? ( kinda [OT] )
|
|
| Wiggins D'Anconia 2004-05-22, 11:31 am |
| B McKee wrote:
> Yeah, ok, this isn't completely on topic. Please humour me (or at least
> flame me politely). I need to redirect people to a perl-CGI script....
>
> I have written a perl script that generates a series of active web
> pages. It's in the cgi-bin and works fine when accessed directly
> eg:
>
> http://www.example.com/cgi-bin/index.pl
>
> So, now I want to redirect anyone going to http://www.example.com
> to the above link instead.
>
> I thought simply putting
> Redirect permanent index.* /cgi-bin/index.pl
> in a .htaccess file would work - but it doesn't seem to do anything.
> Googling about seems to say it should work.
> My ISP does allow .htaccess files as I'm using them elsewhere for auth
> purposes.
>
> What am I doing wrong? Or what should I be doing instead?
>
> Input appreciated.
>
Are you using Apache, and what version?
It appears that the second portion of the Redirect must be an absolute
link, and I don't know that the first can be a regex/glob constuct...
for that you appear to need RedirectMatch.
http://httpd.apache.org/docs/mod/mo...s.html#redirect
Alternatively,
I believe you can put Rewrite rules into a .htaccess, at least depending
on the base server config, and I use the following in my apache conf to
do exactly what you state:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/$ /cgi-bin/index [R,L]
</IfModule>
Of course that is also assuming that mod_rewrite is available....
HTH,
http://danconia.org
| |
| Wc -Sx- Jones 2004-05-22, 11:31 am |
| B McKee wrote:
> I thought simply putting
> Redirect permanent index.* /cgi-bin/index.pl
[ without mod_rewrite ]
Redirect permanent / http://www.example.com/cgi-bin/index.pl
But mod_rewrite would be best - as the OP stated...
Over all this is a bad Idea... after a few more
months of CGI programming you may discover why.
Also, you may want to create a simple
index.html file or a plain index.cgi in
DocuementRoot to either
HTTP-EQUIV=Refresh content=0;URL=blah blah
Or inside the index.cgi simply print-out
Location: http://www.example.com/cgi-bin/index.pl\n\n
( 2 Crs afterward )
HTH/Sx
--
http://www.usenix.org/publications/perl/
| |
|
|
| Zentara 2004-05-22, 11:31 am |
| On 07 Apr 2004 22:54:17 -0400, binlinux@hotmail.com (B McKee) wrote:
>Yeah, ok, this isn't completely on topic. Please humour me (or at least
>flame me politely). I need to redirect people to a perl-CGI script....
>
>I have written a perl script that generates a series of active web
>pages. It's in the cgi-bin and works fine when accessed directly
>eg:
>
>http://www.example.com/cgi-bin/index.pl
>
>So, now I want to redirect anyone going to http://www.example.com
>to the above link instead.
>
>I thought simply putting
> Redirect permanent index.* /cgi-bin/index.pl
>in a .htaccess file would work - but it doesn't seem to do anything.
>Googling about seems to say it should work.
>My ISP does allow .htaccess files as I'm using them elsewhere for auth
>purposes.
>
>What am I doing wrong? Or what should I be doing instead?
>
>Input appreciated.
>
>Brian
This is probably this simplest solution, although it may not be
the best.
Why not just move your /cgibin/index.cgi to be your index.cgi?
You can tell apache to use index.cgi as the default page
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.php
</IfModule>
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
| |
| Wiggins D Anconia 2004-05-22, 11:31 am |
|
> On 07 Apr 2004 22:54:17 -0400, binlinux@hotmail.com (B McKee) wrote:
>
>
> This is probably this simplest solution, although it may not be
> the best.
>
> Why not just move your /cgibin/index.cgi to be your index.cgi?
>
> You can tell apache to use index.cgi as the default page
>
> <IfModule mod_dir.c>
> DirectoryIndex index.html index.cgi index.php
> </IfModule>
>
That would make the index.cgi a directory index which means it would be
printed as is rather than executed. You would also need to turn on
ExecCGI and add a handler for .cgi....
At least that is my understanding....
http://danconia.org
| |
| B McKee 2004-05-22, 11:31 am |
| Begin forwarded message:
> B McKee wrote:
> It appears that the second portion of the Redirect must be an absolute
> link, and I don't know that the first can be a regex/glob constuct...
> for that you appear to need RedirectMatch.
> http://httpd.apache..org/docs/mod/m...s.html#redirect
> Alternatively,
> <IfModule mod_rewrite.c>
> RewriteEngine on
> RewriteRule ^/$ /cgi-bin/index [R,L]
> </IfModule>
> From: WC -Sx- Jones <sx@insecurity.org>
> [ without mod_rewrite ]
> Redirect permanent / http://www.example.com/cgi-bin/index.pl
>
> But mod_rewrite would be best - as the OP stated...
> Also, you may want to create a simple
> index.html file or a plain index.cgi in
> DocuementRoot to either
> HTTP-EQUIV=Refresh content=0;URL=blah blah
> Or inside the index.cgi simply print-out
> Location: http://www.example.com/cgi-bin/index.pl\n\n
> Wiggins d'Anconia wrote:
>
> This is also possible:
> RedirectMatch permanent /(.*) http://www.example.com/cgi-bin/index.pl
> (It's just another way...)
> I would always use mod_rewrite myself...
>
> Why not just move your /cgibin/index.cgi to be your index.cgi?
> You can tell apache to use index.cgi as the default page
> <IfModule mod_dir.c>
> DirectoryIndex index.html index.cgi index.php
> </IfModule>
>
> That would make the index.cgi a directory index which means it would be
> printed as is rather than executed. You would also need to turn on
> ExecCGI and add a handler for .cgi....
> At least that is my understanding....
>
Thanks all for the various suggestions. I tried most of them :-)
None of them worked. It turns out all of them were 'foiled' by the
settings
used by my ISP. Executables only in the cgi-bin and no directives in
..htaccess
files I gather.
So, I did what I probably should have done in the first place and
called them.
They went ahead and did something (they were fuzzy but I suspect it was
mod_rewrite)
and I'm a happy camper.
I have saved your instructions for future use on my own web-server.
Thanks again
Brian
|
|
|
|
|