Page 1 of 1

problem with apache rewrite, causes 404s from CMSMS for other pages and dirs

Posted: Wed Feb 28, 2007 12:03 am
by jptechnical
This on a clean install of 1.04 on a pretty run-of-the-mill cpanel/whm host. Details below:

Code: Select all

Operating system	Linux	
Kernel version	2.4.22-1.2199.nptlsmp	
Machine Type	i686	
Apache version	1.3.37 (Unix)	
PERL version	5.8.1	
PHP version	4.4.4	
MySQL version	4.0.27-standard	
cPanel Build	10.9.0-CURRENT 82	
cPanel Pro	1.0 (RC36) 
I also have osCommerce running in /shop and /shop/admin is protected with htaccess/htpasswd and has worked fine for a long time. I had to rebuild the cms, was tired of upgrading (from like 3 years ago) and started fresh. Man, alot has changed and I had so many html blobs and phplayers issues as I have upgraded to each major release that I wanted to redo the template anyway.

Long story short, the .htaccess in the /docs directory broke the htaccess/htpasswd, strangest thing. I couldn't find my old .htaccess file, like a moron I deleted it thinking I wouldn't possibly need it it ;-). I searched the forums and found an older one and swapped it out and it fixed the problem, so I thought. But it is back again. I get a 404 on all password protected directories now. Any ideas?


I have this:

Code: Select all

#Rewrites page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

I thought it worked, then it didn't.


*** Update

I have now confirmed that it is sitewide, turning on the rewrite passes everything through the cms site because I can enable the custom 404 and that is what is displayed. If I disable the password on the directory then it seems it works just fine, with the password protected directory then ALL paths are passed through it (you can't go to /uploads, you get the same 404). This is NOT the case on a bunch of other sites running cmsms. I am putting in a support request with my host tech. I would be interested in any possible ideas other may have.

Re: problem with apache rewrite, causes 404s from CMSMS for other pages and dirs

Posted: Tue Aug 28, 2007 7:14 pm
by Pierre M.
Hello,

If I understand well...
-you have CMSms installed in your root w3 directory (domain.net/index.php, domain.net/admin etc.), not in a /cmsms subfolder.
-you have other software in /other with was protected by old /.htaccess
-you have lost this /.htaccess by replacing it with the sample of CMSms in /docs.
-this current .htaccess doesn't rewrite well (or rewrites too much) and doesn't protect /other, hence the issue.

Try something like this sample :
/other/.htaccess

Code: Select all

AuthType Basic
AuthName "/other has Password Required"
AuthUserFile /www/passwords/password.file
AuthGroupFile /www/passwords/group.file
Require Group admins
main /.htaccess

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^/other
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Of course, YMMV.

Pierre M.

Re: problem with apache rewrite, causes 404s from CMSMS for

Posted: Thu Sep 29, 2011 1:56 pm
by dont

Code: Select all

####################password dir fix
RewriteCond %{REQUEST_URI} /sdir1/(.*)$
RewriteRule ^.*$ - [L]
ErrorDocument 401 /401.html
####################
this is my solution, you must make also the blank 401.html in your root
replace sdir1 for your dir.