Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

How to disallow access to site except me?

share|improve this question
    
ok, if i rent just hosting? –  user3070 Nov 26 '10 at 11:00
    
You can edit your questions if you want to add info or reword the question. –  Lèse majesté Nov 26 '10 at 13:05
    
OKEY, Thank you! –  user3070 Nov 27 '10 at 19:36

4 Answers 4

up vote 3 down vote accepted

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.

share|improve this answer

(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

share|improve this answer
    
Why do people still use basic authentication instead of digest? –  Lèse majesté Nov 26 '10 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 '10 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 –  Lèse majesté Nov 26 '10 at 15:32
    
Ahhh, the wonders of having multiple versions of your software's documentation. :/ –  John Conde Nov 26 '10 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. –  Lèse majesté Nov 26 '10 at 16:46

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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