4

How to disallow access to site except me?

2
  • ok, if i rent just hosting?
    – user3070
    Nov 26, 2010 at 11:00
  • You can edit your questions if you want to add info or reword the question. Nov 26, 2010 at 13:05

4 Answers 4

3

For the sake of variety: if you have a static IP address you could block all IP addresses except yours:

order deny, allow
deny from all
allow from xxx.xxx.xxx.xxx

Just change xxx.xxx.xxx.xxx to be your IP address.

2

(on Apache Server) Steps

  • Choose the directory you wish to protect You wish to protect the whole site then chose "public_html". Also chose a directory e.g. "../password" to store the password in.
  • Create a file .htaccess and .htpasswd
  • Edit .htaccess with your favourite editor to contain the following:

AuthUserFile /path/to/password/.htpasswd

AuthGroupFile /dev/null

AuthName "Authentication Query Name"

AuthType Basic

  • place .htaccess in to be protected folder
  • Edit .htpasswd to contain the username and passwords. Syntax [username]:[md5-encrypted-password] Use a generator to make the encryption e.g.

    foobar:Fkb3n2r1vsba

  • place .htpasswd in chosen directory and make sure you change the directories permission so only the server may access e.g. run chmod g+r,g+x,o-r,o-x password

5
  • Why do people still use basic authentication instead of digest? Nov 26, 2010 at 13:06
  • According to the Apache website "This module implements HTTP Digest Authentication. However, it has not been extensively tested and is therefore marked experimental."
    – John Conde
    Nov 26, 2010 at 15:18
  • @John: I have a feeling that documentation hasn't been updated in a long time. Netscape 7 was released 6 years ago, and pretty much all browsers currently in use support HTTP Digest. See the 2.2 documentation: httpd.apache.org/docs/2.1/mod/mod_auth_digest.html Nov 26, 2010 at 15:32
  • Ahhh, the wonders of having multiple versions of your software's documentation. :/
    – John Conde
    Nov 26, 2010 at 15:35
  • The sad thing is, whenever you search for Apache documentation/mods/features, the 1.0 documentation is what shows up on Google. So then you have to go to the 1.0 documentation and click on the little link up top that tells you to check out the 2.2 docs. Nov 26, 2010 at 16:46
0

If you run an Apache server just make a .htpasswd file and upload it to your main directory.

0

I once came up with a solution I call .htaccess maintenance mode. It uses mod_rewrite, restricts the site to your IP address, and redirects other people to another URL.

RewriteEngine On

RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.100
RewriteCond %{REQUEST_URI} !^/403\.html$
RewriteRule ^(.*)$ http://site.com/403.html [R=307,L]

A little explanation: The first line checks the IP address. The third one redirects the user to the 403.html page. Basically it would redirect all pages to 403.html, including 403.html - the second line prevents that so users can't go into an endless redirect loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.