Forum Topic: Applying maintenance for another folder
I know rules are inhereted, but is it possible to order a maintenance page for another folder?
For example, if I have example.com that is an active site, and a subfolder example.com/subfolder/
where I want a user to test his own scripts with his own .htaccess file and all, can I have example.com/.htaccess
file with a maintenance script pointing to that subfolder only (main site would not be on maintenance) so only his IP can access it?
Where you have:
# Site maintenance mode
# edit the IPs to match your own
# see chapter 6.3 for details
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^123\.456\.789
# RewriteCond %{REMOTE_ADDR} !^111\.222\.333
RewriteRule .* - [R=503,L]
</IfModule>
<IfModule mod_headers.c>
Header always set Retry-After "3600"
</IfModule>
I thought that just by adding
RewriteCond /subfolder/
…would work, but it did not, maybe Im missing a parameter, but I dont know what exactly, any ideas?
6 Replies to “Applying maintenance for another folder”
No, but it is possible to disable mod_rewrite in any (sub) directory:
RewriteEngine off
More info:
https://perishablepress.com/three-ways-to-allow-hotlinking-in-specific-directories/
Oh, so maybe it will be easier just to declare a specific IP has rights to the folder, and let him do what he wants inside there like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*)?subfolder/.*$ [NC,OR]
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.012$
RewriteRule ^(.*)$ - [R=403,L]
</IfModule>
Is that correct?
=========
Side note:
I used your contact form thru perishablepress.com and got this error:
Hi. This is the qmail-send program at example.com.
I’m afraid I wasn’t able to deliver your message to the following addresses.
This is a permanent error; I’ve given up. Sorry it didn’t work out.
xxx.xxx.xx.x does not like recipient.
Remote host said: xxx x.x.x emaildomain is not your domain is ours check smtp auth in your configuration (Mark the option my server requieres authentication in your email client): email@domain (my email)
Giving up on xxx.xxx.xx.x.
Anyway, just for the record, the message was:
———————————————
Hi Jeff, I was testing your blackhole script and my whole site went blank, I reviewed the comments here and saw that somebody else had the problem too:
https://perishablepress.com/blackhole-bad-bots/
I think I found the mistake, in the blackhole.php
file, at the end there is a die command after the closing bracket for the previous if condition (valuates if it has been included), after I passed that die command before the closing if bracket everything worked fine.
Just a comment in case others are having trouble with it. Chao
———————————————
“Is that correct?”
I haven’t tested it but it looks sound, but advise to test well.
“I used your contact form thru perishablepress.com and got this error: …”
I just retested my contact form at Perishable Press via proxy server and it sent thru just fine. It could be some sort of local issue or who knows what else.. Also it looks like the IP may have triggered something.. Would you able to try again using a proxy server to access the contact form? For example, a proxy such as https://www.proxyserver.com/ – if you can try again and let me know that would be helpful and appreciated. Also it could be that your host is blocking access, which may sound strange but it happens.
“Hi Jeff, I was testing your blackhole script and my whole site went blank, …”
Thanks for this, I will try to get it posted or fixed up in the next update of the script. Others have reported it as well, just need to take a few moments to jump in there.
UPDATE: Just recieved your email, but dont know why I recieved an error just like last time.
No, I keep trying from different ips and seams like a 530 5.7.1 authentication error from your exchange server.
A “530 5.7.1 – Client was not authenticated” error is usually related to the SMTP User Authentication details in your email settings.
Seams like it is a Microsoft Exchange related problem, here is what I found:
http://www.servolutions.com/support/articles/exchange2007clientnotauth.htm
http://smtp25.blogspot.com/2009/04/530-571-client-was-not-authenticated.html
http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_28286177.html
=========================
Another Side note (let me know if Im bugging you too much, haha):
I have a small gallery set up and I tested your htaccess for the directory where the images are according to the following script:
Ref: https://digwp.com/2012/09/secure-media-uploads/
# secure uploads directory
<Files ~ ".*\..*">
Order Allow,Deny
Deny from all
</Files>
<FilesMatch "\.(jpg|jpeg|jpe|gif|png|tif|tiff)">
Order Deny,Allow
Allow from all
</FilesMatch>
It works ok (doesn’t allow direct directory browsing nor uploading stuff), but the problem I found is that whenever an image ends in JPG for example (all uppercase) the image wont show up in the gallery, uppercase extensions are sometimes used by default on some cameras (according to config) or saved as so after editing by some photo editor.
I suppose the same applies to the other extensions.
Anyway I added JPG as so:
(jpg|JPG|jpeg|jpe|gif|png|tif|tiff)
… and it worked.
Dont know if I can use a NC (no case) directive somehow in this kind of filematch stuff.
Thanks for the update and infos about the email stuff. Thankfully I’m not running any Microsoft software on my server, so that couldn’t be the issue. As long as you are able to send and receive email, it’s all good. Sometimes glitches happen that aren’t worth pursuing. But if you continue to experience the issue, please let me know.
As for your other thoughts:
“It works ok (doesn?t allow direct directory browsing nor uploading stuff)”
I use this technique on many sites, and no it doesn’t allow directory browsing, and yes it does indeed allow file uploading for any allowed file type. That’s the whole point, and it works flawlessly.
“Dont know if I can use a NC (no case) directive somehow in this kind of filematch stuff.”
[NC]
does not work with Files/FilesMatch directives. Neither does (?i)
. But you can use regex to make things a bit simpler, for example something like this:
([Jj][Pp][Ee]?[Gg]|[Pp][Nn][Gg])
..and so on. Personally I just keep all file extensions lowercase, but I undertand that may be difficult to enforce if multiple people are involved with uploading etc.
Oh, I see now, the regex like you explain here is for any case match, thanx for that.