WebFaction
Community site: login faq

Hi all,

Apologies for those who've probably seen this before, I've tried my luck on Google but my limited Apache knowledge is letting me down!

I built a Wordpress site at http:/www.mydomain.com/dev and used .htaccess to password protect it while I had a landing page in the root directory. I've now shifted the site into the root directory http://www.mydomain.com but would like to keep this folder and it's contents protected - its not a members area or anything, more just for myself.

My issue now is that trying to access just http://www.mydomain.com results in a password prompt which is stemming from that sub directory's .htaccess. The root folder itself has it's own .htaccess file which I assume is what's causing the problem. Aside from this issue, the site itself is working fine, no permalink or other directory issues.

Below is the .htaccess file in the root directory

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule> 
# END WordPress

and the .htaccess in the sub-directory:

AuthUserFile /home/myuser/.htpasswd
AuthName Password
AuthType Basic
require valid-user

<Files .*>
order allow,deny
deny from all
</Files>

I've checked that the link to .htpasswd is correct, and I believe it must be something little I'm missing but if anyone has a solution that would be awesome.

Thanks in advance

asked 21 May '14, 12:56

mk87
1314
accept rate: 0%


I looked up your account so I could test the actual site.

What I found was that you're seeing the authentication prompt because your site is trying to load some CSS resources from the protected directory.

So, fix whatever paths in your theme so that they don't try to load resources from that directory, and the problem should be solved.

Hope that helps!

permanent link

answered 22 May '14, 00:56

seanf
12.2k41836
accept rate: 37%

That was it! I'd had that in there during development and completely forgot about it, was too caught up thinking the problem lay in .htaccess... Thanks heaps for your help!

(22 May '14, 01:09) mk87

Hi,

In your .htaccess file in the sub-directory you are trying to protect can you add this

AuthUserFile /home/myuser/webapps/myapp/.htpasswd
AuthName "Password"
AuthType Basic
require valid-user

Also place your htpasswd file there too.

Your htaccess and htpasswd files shouldn't be located directly under your home directory. They should be in your application folder as Apache needs to have access to the files which is perhaps why it isn't working.

There is a good guide on this at

http://docs.webfaction.com/software/static.html#password-protecting-a-directory-with-a-static-cgi-php-app

If you are still having issues please log a ticket through support suite and we will try assist you.

permanent link

answered 21 May '14, 14:16

muhammadp ♦♦
112
accept rate: 0%

edited 21 May '14, 15:05

Hi, thanks for your quick answer - it's still not working unfortunately. I still get a password prompt coming up on http://www.mydomain.com despite having both the .htaccess and .htpasswd placed where you mentioned. Could it be the .htaccess that Wordpress creates in its installation directory have anything to do with it? I'll keep trying and if nothing works, I'll log a ticket.

Cheers

(22 May '14, 00:21) mk87
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×244
×45
×33
×15

question asked: 21 May '14, 12:56

question was seen: 3,651 times

last updated: 22 May '14, 01:09

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM