Forum

Thread tagged as: Problem, Configuration, Runway

Perch Runway preventing the use of htaccess/htpasswd on static file

I'm using Perch Runway to manage my site, but I need to post one file in a password-protected directory. I can access the file before it is password-protected, but once I place the htaccess file in the directory and try to load the page I get the following error:

Warning: include(/home/mchtorg/mcht.org/perch/templates/pages/errors/404.php): failed to open stream: No such file or directory in /home/mchtorg/mcht.org/perch/core/runway/start.php on line 31

I believe this is being called by the URL rewriting rules being used by Runway, but I'm not 100% sure. My rewrite rules are just the bog-standard:

Perch Runway

RewriteEngine On RewriteCond %{REQUEST_URI} !^/perch RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* /perch/core/runway/start.php [L]

Appreciate any help that anyone can offer. Thanks!

Timothy Swan

Timothy Swan 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Exclude your password protected folder with a rewrite condition in the same way that the /perch folder is excluded.

Drew McLellan said:

Exclude your password protected folder with a rewrite condition in the same way that the /perch folder is excluded.

Sorry, can you be a little more explicit?

Drew McLellan

Drew McLellan 2638 points
Perch Support

RewriteEngine On 
RewriteCond %{REQUEST_URI} !^/perch 
RewriteCond %{REQUEST_URI} !^/yourfolder 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* /perch/core/runway/start.php [L]

That doesn't appear to have fixed it.

If I disable all URL rewriting the htaccess/htpasswd works, bringing up a login box as expected. If I re-enable the URL re-writing it seems to want to send everything through Perch Runway, even if I've disabled the folder that I want to password-protect as you show above.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Can you get to the /perch folder? If so that demonstrates that this method is working to exclude a folder so you may need to ask your host for assistance.

Thanks for all of your help. Turns out it is now required to put

ErrorDocument 401 "Authorisation Required"

in the htaccess file and that was the problem. That, and that I was missing the perch>templates>pages>errors. Things are now working as expected.