08-21-2002, 05:21 AM
I am calling htaccess from:
using the htaccess code:
ErrorDocument 401 /tour.html
activating that error results in:
tour.html document loads, BUT it loads FROM the 'webmasters' directory,
('.../webmasters/main.html' is still in the address bar!)
Because of this none of the tour image sources are correct and none show.
AND the htaccess continues to request the username-password access info.
At this point the only thing which works for me is to insert HTML
into the htaccess:
ErrorDocument 401 "<meta http-equiv="refresh" content="0;URL=http://www.mysite.com/tour.html">"
Which does what I want...to be redirected to the COMPLETE tour page AT its correct location.
But is this really the only way to get this to happen correctly?
08-21-2002, 06:03 PM
As I can understand with mysite-root/webmasters/.htaccess is
The home for your site is mysite-root/
You should write .htaccess file in your default root only so that it work for whole site.
The content of .htaccess
ErrorDocument 401 /tour.html
After writeing the content to .htaccess please put this file in
This will solve your problem.
08-22-2002, 03:24 AM
Except that I definitely don't want to restrict access to the root site as that is the free-to-the-public area. I need to only restrict access to the webmasters directory.
Basically, (from what I can infer from a strange description ;) ) you've got a lot of strange entries...you're missing some basic logic about placement of specific pieces.
yoursite/webmasters/ is protected, correct? With whatever method. And you want people who do not have the response to your authentication challenge to be redirected (via the 401 error code) to yoursite/tour.html?
First of all, your 401 redirect is going to be global, no matter where they try and enter, they are always going to /tour.html if they fail. (Additionally, this is not exactly the best way to do it, Vaneet is correct that this 401 redirect htaccess should be placed IN yoursite/webmasters/ with your pw protecton, but have the tour.html redirect to yoursite/tour.html as usual)
Also, your /tour.html should be using virtual paths to its images (such as /images/file.gif being equivalent to yoursite.com/images/file.gif so that no matter where in the site they are, the images will be referenced correctly).
Also, htaccess does not change the URL when it error redirects...never has. Reason being that most owners do not want people to know the direct URL to their error pages (and other minor aesthetics--and No, you can't simply add [R,L] on the end of your ErrorDocument to get it to redirect and update the location--which is basically what you want it to do).
What I would do is create an entrance page to your webmasters area, outside of webmasters, that warns the people they need authentication and offers a link to your tour (plus you can use this area to notify them of outages and other updates). It has a login link to it that simply goes to webmasters. Now in webmasters you have your htaccess with authentication, but you also have a redirect that says 401 to your intro page. You can also then go a step further and add a query string to your 401 redirect and then on your intro page test to see if the query string is there. If the query is there, you can say 'Hi, looks like you failed the test!' or whatever since you know they tried to enter unsuccessfully, if the query string is not there, you know this is their first time trying it out in this session...
Also, since this isn't PERL/CGI but actually APACHE, I'm moving this to the general server side forum...
08-20-2009, 03:06 AM
I know this is old but im sure someone can use this help. I agree with the post above as it is global. Instead of guessing there are tools out there to do this like http://tools-for-webmasters.com and others. I use this for about 90% of my needs.