Password Protection - Question


#1

I set up a password-protected directory, for a few pages on my website. Of course, none of the pages in the password-protected directory show images or access css — which makes sense, since the password-protected pages are now in a new folder.

Any suggestions on the easiest way to solve this problem?

Thank you,

  • J

#2

How are you referencing the CSS and image files in those pages?

You should generally reference these resources using absolute paths, e.g.

<link rel="stylesheet" type="text/css" href="/path/to/style.css">

(Note the leading slash — this indicates that the path is to be interpreted relative to the root of your domain, rather than the current directory.)


#3

Hi Andrew,

Thank you for posting. I believe you mean that I should just put a slash in front of my href and src codes, which I did and it works now:

But I have a new problem: I’m not being prompted for my password (though I was, before I inserted the slash). Any idea why not?

Thanks,
Jeff


#4

Most likely because you’ve already logged into the password-protected section of the site. Once you’ve entered the password for a protected area once, your browser typically remembers it for as long as your browser is open, even if you don’t explicitly ask it to remember. (Otherwise you’d have to enter your password every time you tried to load another protected page or file, which would be pretty obnoxious.)

If you’re testing a password-protected area of your site, I’d strongly recommend using your browser’s private browsing feature to test it (e.g, “Private Window” in Firefox, “Incognito Window” in Chrome), as these windows will start off logged out of any password-protected areas, and you can close them and open a new one to log out.


#5

That makes sense – thanks again, Andrew!