Jump to content

How to hide a webpage


NotionCommotion

Recommended Posts

I have a particular PHP file which is publicly located, however, I don't want anyone but me to access.  Below are my thoughts how to do so.  Please comment.

  1. Use an uncommon name, and definitely not index.php.
  2. Either include a file called index.html in the same directory, or set up Apache not to show them using Options -Indexes, or maybe both for good measure.
  3. Require some variable to be set to a given value in either the GET or POST array, and if not set, throw a 404 header and display the 404 missing file HTML.
  4. If user accesses page and is not logged on as determined by a session value, display a log-on page.
  5. Prevent indexing by either putting <meta name="robots" content="none" /> in the HTML, and using header("X-Robots-Tag: noindex, nofollow", true); in the PHP, or maybe both for good measure.
Seem reasonable?  Anything else?  Thanks
Link to comment
Share on other sites

You shouldn't really focus too much on making sure nobody can find it. Just make sure that nobody can use it if they do without proper authorization. So long as you don't publicly publish any links to the page it will generally not get found/accessed. You can of course add the noindex directive to request search engines do not index it as well, just incase they happen to find it somehow.

 

 

The important thing is that it does nothing unless the person has the proper authorization. You should be able to publish it as a giant CLICK HERE link on your home page without risk.

 

All that said, what exactly does this script do? Can you move it out of the web root and make it completely inaccessible and still function? If it's for a cron job for example, it should be inaccessible from the web and run via php's CLI executable.

Link to comment
Share on other sites

All that said, what exactly does this script do?

 

Various development and configuration tools.  Currently, I have a bunch of scripts such as delete the database and rebuild it from scratch.  Once in production, I will obviously not want that one!  Other scrips are to modify the database to add a new page to the application.  Currently, I have the scripts located in a non-public directory, and have a publicly accessible directory protected with an Apache password with contains PHP files with a single require('/var/www/private/some_file.php').  I want to clean it up and have one location to access all of them.

 

Yes, I cold move them out of the web root, but don't want to currently.  And I agree it should be robust enough so no one could do anything with it even if they found it, but what if I miss something?  Adding a little to hiding it just seemed like an easy way to add some extra insurance.

Link to comment
Share on other sites

I put all files like that in a password protected directory. When I have to do site maintenance that requires a site be down for a specified period, I redirect all traffic to the "Scheduled Maintenance" page except my own IP address. And as mentioned, any directory or file that you don't want published to the world should be a noindex in the robots.txt file.

Edited by hansford
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.