CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Not exactly Perl, not typical htaccess question

 



jr
Novice

Oct 17, 2001, 2:43 PM

Post #1 of 9 (646 views)
Not exactly Perl, not typical htaccess question Can't Post

I know you can do

redirect oldloc newloc

in an htaccess file to automatically forward a page request to a new page, but what if I wanted a page to be forwarded to a default maintenance page for example?

Say that a site is down for an update and I want all requests for any page within the domain (EXCEPT for the maintenance page) to be forwarded to the maintenance page...

Anybody have any idea what I am talking about, or am I spouting off more inane drivel?



yapp
User

Oct 17, 2001, 11:43 PM

Post #2 of 9 (641 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

I don't know, but maybe this could help otherwise.

There is something allowed in a .htaccess file called ErrorDocument.

Can't you simply redirect all 404 errors to your maintaince page?



jr
Novice

Oct 18, 2001, 7:42 AM

Post #3 of 9 (639 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

Yes, I can redirect the 404, but that wouldn't get me to what I am trying to do since there would be no 404 code being returned. The pages are in existence, but I would want all requests, 200 or 404, to be forwarded to this maintenance page.

Just thought of it, but maybe I could do a redirect based on code 200 that is in the htaccess in the root directory, then specify a htaccess in the maintenance directory that does not do the redirect based on any code, so as to avoid an infinite loop of redirects....

I'd have to try that out, though...



yapp
User

Oct 20, 2001, 6:12 AM

Post #4 of 9 (632 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

No what I mean is this (I looked for the answer for you)
We're not talking about the client, but about the server.
Any request that is made, will be redirected to an error page IF the server reply WILL BE 404 (before it's send to the client)


Add this to the .htaccess file

ErrorDocument 404 http://www.you.com/errors/404.html


All the pages not found will be redirected to the error page.
You can add your own lines aswell here.



jr
Novice

Oct 20, 2001, 9:00 AM

Post #5 of 9 (628 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

This would not work, the server is not going to be returning a 404 error code, like I said, the pages will be there, but I want them all to automatically redirect, status code has nothing to do with it. Most will return a 200, rarely a 404 since the pages being requested will almost surely be on the server, thus a 200 status code.

I haven't tested this, but mod_rewrite is probably what I need to use, and this code might do it:


Code
AuthUserFile /dev/null 
AuthGroupFile /dev/null
RewriteEngine On
RewriteCond %{HTTP_REFERER}!>http://mysite.com[NC]
RewriteCond %{HTTP_REFERER}!>http://www.mysite.com[NC]
RewriteCond %{HTTP_REFERER}!>http://myipaddress[NC]
RewriteRule /*http://www.mysite.com/maintenance/[R,L]



yapp
User

Oct 21, 2001, 9:54 AM

Post #6 of 9 (622 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

Sorry for that, I missed that explanation. (I'm not the only one Wink )

Unfortunately, that's also the point where my knowledge about .htaccess files ends. I guessed my previous answer it could help you.

I hope you can find yourself an other website where the answer could be found. Crazy[cry]Mad



jr
Novice

Oct 22, 2001, 7:44 AM

Post #7 of 9 (617 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

No problem, Yapp...I apreciate the effort, tho :)

I'm still playing with, maybe one day I'll have to just give it up and go with a more 'simple' version like xssi redirects based on a global variable that can be modified via an include file (kind of an ugly way to do it, but it does work).

Thanks again



yapp
User

Nov 6, 2001, 10:39 AM

Post #8 of 9 (608 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

Weee!

I just discovered some cool link, and I immediately thought about your topic here.,
http://httpd.apache.org/docs/mod/directives.html

Yet an Other Perl Programmer

_________________________________
Find out more about programming
http://www.cool-programming.f2s.com


yapp
User

Nov 6, 2001, 10:39 AM

Post #9 of 9 (608 views)
Re: Not exactly Perl, not typical htaccess question [In reply to] Can't Post

Weee!

I just discovered some cool link, and I immediately thought about your topic here.,
http://httpd.apache.org/docs/mod/directives.html

(HTTP headers) and (.htaccess files in Apache) also supports a redirect code, check that out to solve your problem.

Yet an Other Perl Programmer

_________________________________
Find out more about programming
http://www.cool-programming.f2s.com

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives