- Create a .htpasswd file:
$ htpasswd -c .htpasswd <username> password:
- Create or add these lines to .htaccess file:
- To protect a directory:
AuthUserFile /full/path/to/.htpasswd AuthType Basic AuthName "Protected Folder" Require valid-user
- To protect a file:
AuthUserFile /full/path/to/.htpasswd AuthType Basic AuthName "Protected Page" <Files "protected_page.html"> Require valid-user </Files>
- To protect a directory:
Showing posts with label httpd. Show all posts
Showing posts with label httpd. Show all posts
Tuesday, November 15, 2011
How to protect a web page with htaccess with a password
Friday, April 9, 2010
How to Prevent Files from Being Used by Other Website?
Added these lines to your .htaccess file.
RewriteEngine On RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC] RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
Thursday, July 3, 2008
Ways to Force HTTPS on HTTP
-
Add this to your httpd.conf:
SSLRequire %{HTTP_HOST} eq "www.mydomain.com"
- Or try this:
# Turn on Rewriting RewriteEngine on # Apply this rule If request does not arrive on port 443 RewriteCond %{SERVER_PORT} !443 # RegEx to capture request, URL to send it to (tacking on the captured text, stored in $1), Redirect it, and this is last rule. RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R,L]
-
Append the following line to httpd.conf:
Redirect permanent / https://www.mydomain.com/
-
Or try this:
<NameVirtualHost 122.123.124.1:80> ServerName mywebsite.com:80 ServerAlias http://www.mywebsite.com:80 ServerAlias 122.123.124.1:80 Redirect permanent / https://www.mywebsite.com/ </VirtualHost>
-
Add the following lines to .htaccess:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Make sure you have this line in your httpd.conf file:LoadModule rewrite_module modules/mod_rewrite.so
-
Or try this:
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R,L]
$ /etc/init.d/httpd restart
Subscribe to:
Posts (Atom)