matfish Posted July 1, 2009 Share Posted July 1, 2009 Sorry - didn't know which section to post this in... Is there a way to allow the root index.php file to be displayed to all, however making all other directories password protected without putting a .htaccess file in every directory? The idea being I would like a holding page to be present on the root of the domain, but start development beyond that which would be password protected? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/ Share on other sites More sharing options...
Bendude14 Posted July 1, 2009 Share Posted July 1, 2009 How about just blocking it from been listed in the search engines with a robots.txt file... nobody else is ever going to know your site is their then so no need for password protection. Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867161 Share on other sites More sharing options...
matfish Posted July 1, 2009 Author Share Posted July 1, 2009 Thanks for the reply, I have already put a robots.txt file in place and I know that crawlers are supposed to abide by these rules set - however in the past I have still found blog related pages on Google/Yahoo listings before it's offical launch. Which is why I wanted something a bit more secure. Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867172 Share on other sites More sharing options...
Bendude14 Posted July 1, 2009 Share Posted July 1, 2009 a quick google yeilds lots of results to protect the whole site using .htaccess and even allow your access without a password based on your ip address http://www.evolt.org/ultimate_htaccess_examples Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867187 Share on other sites More sharing options...
UQ13A Posted July 1, 2009 Share Posted July 1, 2009 im not so sure about this one but, how about adding a blank index file in each directory that you dont want people to access. Which you can then redirect people to the main page Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867225 Share on other sites More sharing options...
Bendude14 Posted July 2, 2009 Share Posted July 2, 2009 UQ13A That will only stop people listing the contents of a directory and redirect them if they try to do so or visit the index page. It will not stop them viewing other files in the same folder. Ben Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867531 Share on other sites More sharing options...
johnathanhebert Posted July 2, 2009 Share Posted July 2, 2009 This should do it... The "RewriteRule" says that if the path part of the URL does not start with "/index.php" then -- the "-" means do not rewrite the URL, just process the flag (which is the last part in square brackets) -- the "[F]" means send back a "Forbidden" response, which is an HTTP 403 message header RewriteEngine On RewriteRule !^/index.php - [F] Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867534 Share on other sites More sharing options...
Bendude14 Posted July 2, 2009 Share Posted July 2, 2009 johnathanhebert That would also block him from viewing any other page than his index page.... Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867553 Share on other sites More sharing options...
johnathanhebert Posted July 2, 2009 Share Posted July 2, 2009 Right... isn't that what he requested in the original post? Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867575 Share on other sites More sharing options...
Bendude14 Posted July 2, 2009 Share Posted July 2, 2009 No he requested that Index.php was shown and all other directories where password protected. Your solution simplies gives them a 403 error if he or anyone else trys to access any other file than index... Quote Link to comment https://forums.phpfreaks.com/topic/164396-htaccess-file-issue/#findComment-867640 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.