Wednesday, April 08, 2009

Wordpress htaccess clashes with sub-directory

The situation:

Wordpress installed in root / with its default .htaccess file
I had another script installed in /otherscript sub-directory with .htaccess/.htpasswd protection.

The problem:

Trying to access the /otherscript sub-directory creates a Wordpress 404 error, rather than the pop-up login box you'd expect to see.

The solution:

Simply edit the Wordpress .htaccess and at the very top of the file add:
ErrorDocument 401 default
All thanks for this solution go to Andrew Rollins who blogged about this back in 2008 - I have merely made my own record of it here just in case anything ever happened to Andrew's page. Also if you check his blog posting you'll find some alternatives to the line above, such as specifying a custom 401 page.

8 comments:

Denis said...

FOR THE LOVE OF GOD, THANK YOU FOR POSTING THIS COMMENT!

It's been driving me nuts and I haven't been able to find a solution to the 404 error Wordpress was giving me, until just now!

Thanks,
Denis

Anonymous said...

At last, I can't thank you enough! I had originally given up on this one

Tony said...

SO SWEET, couldn't work this out at all... because other directories without user/pass still worked! but this fixed up my members area access right away... u rock!

Ederson Peka said...

Bull's eye! Thank you very much.

Anonymous said...

I LOVE YOU. This has been bugging me for soooo long. THANK YOOOU!

Beth said...

What I discovered was that when I moved to another server that didn't have indexes turned off by default, I got the 404 on any subdirectory. I was able to resolve it by adding Options -Indexes to my .htaccess file.

Anonymous said...

Thank you soooooooo much! I've spent like half a day trying different htaccess rules combination and neither worked. You saved my day

Neil said...

You are my effing hero!!!!