.htpasswd problems

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
meraj
New Member
New Member
Posts: 5
Joined: Tue Feb 05, 2008 10:38 am

.htpasswd problems

Post by meraj »

Hello all,

I did a search to see if a solution had been posted to this problem before, and this very similar to the problem I'm experiencing:

http://forum.cmsmadesimple.org/index.ph ... 386.0.html

I have CMSMS installed in the web root, and my .htaccess file contains this:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing
# slash to include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
So I am using pretty URLs which work perfectly. But my problem now is that when I try and create a new password protected directory (like /secret for example), trying to access it via the browser returns a 404 instead of prompting for a username and pawword as I was expecting. If i remove the .htaccess file, the password pretection works as expected. I did a little debugging and figured out that it's the last three lines of the .htaccess file that are causing this problem, and unfortunately those are necessary for the pretty URLs to work.

I searched quite a bit and never quite found a simple fix for this that I could understand. Has anyone experienced this problem, and does anyone have any solutions or suggestions? Thanks in advance.

-m
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: .htpasswd problems

Post by Jeff »

I am not the best with .htaccess rewrite rules but try adding these lines to the file at line 4.

Code: Select all

RewriteCond %{REQUEST_URI} ^/(secret/|missing\.html|failed_auth\.html) [NC]
RewriteRule . - [L]
replace "secret" to the name of the directory.
meraj
New Member
New Member
Posts: 5
Joined: Tue Feb 05, 2008 10:38 am

Re: .htpasswd problems

Post by meraj »

ajprog wrote: I am not the best with .htaccess rewrite rules but try adding these lines to the file at line 4.

Code: Select all

RewriteCond %{REQUEST_URI} ^/(secret/|missing\.html|failed_auth\.html) [NC]
RewriteRule . - [L]
replace "secret" to the name of the directory.
thank you for your response. i just gave a try to the above suggestion and unfortunately it did not fix the issue. but i appreciate the attempt! :)

i dont know if it's relevant, but i have custom 404 pages enabled in CMSMS.

-m
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: .htpasswd problems

Post by Jeff »

I went to verify in my .htaccess file this is what I have at the begin of the file so I can go to my stats page.

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats|failed_auth\.html).*$ [NC]
RewriteRule . - [L]
</IfModule>
meraj
New Member
New Member
Posts: 5
Joined: Tue Feb 05, 2008 10:38 am

Re: .htpasswd problems

Post by meraj »

ajprog wrote: I went to verify in my .htaccess file this is what I have at the begin of the file so I can go to my stats page.

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats|failed_auth\.html).*$ [NC]
RewriteRule . - [L]
</IfModule>
Hmm no, still no luck :( It's so frustratingly simple, yet elusive. Any .htaccess wizards have any wisdom to dispense?  :-\

-m
Last edited by meraj on Wed Jun 10, 2009 8:48 am, edited 1 time in total.
Gamonon

Re: .htpasswd problems

Post by Gamonon »

Quite an old post but for me still a problem.

I brought this problem back tot the RewriteRule. If the RewriteRule is removed from the .htaccess file in the root, the .htaccess and .htpasswd work fine for the protected directory.

If the RewriteRule is in place, the files in the protected directory are not found and a 404 is shown.

The RewriteRule is necessary for the Pretty url to work so I can't leave it out.

Does someone has a clue how to solve this?

Thanks
Post Reply

Return to “CMSMS Core”