Difference between revisions of ".htaccess"
From Hostek.com Wiki
Line 43: | Line 43: | ||
</pre> | </pre> | ||
+ | ==Create an IP-based Whitelist to a WordPress login page== | ||
+ | Create a file called '.htaccess' in the same directory as the 'wp-login.php' page. Add the following code: | ||
+ | <pre> | ||
+ | Order Allow,Deny | ||
+ | Allow from 111.222.333.444 | ||
+ | </pre> | ||
+ | Replace 111.222.333.444 with your IP (you can find your IP at http://hostek.com/IP. Note that you can add multiple IP addresses like so: | ||
+ | <pre> | ||
+ | Order Allow,Deny | ||
+ | Allow from 111.222.333.444 | ||
+ | Allow from 111.222.333.444 | ||
+ | Allow from 111.222.333.444 | ||
+ | Allow from 111.222.333.444 | ||
+ | </pre> | ||
[[Category:Linux]] | [[Category:Linux]] |
Revision as of 15:59, 24 May 2017
Contents
Can I use a .htaccess file to password protect a directory?
Yes, on our LINUX servers you can use a .htaccess file to password protect a directory.
The code to perform this is:
AuthUserFile /usr/local/you/safedir/.htpasswd AuthGroupFile /dev/null AuthName EnterPassword AuthType Basic require user wsabstract
Change the File directory to the directory listed in your File Manager.
Enabling Case Insensitive URLs for my Linux site
Add the following to your .htaccess file:
CheckSpelling on
Rewriting all URL requests to WWW.
Add the following to your .htaccess code:
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Rewriting HTTP requests to HTTPS
Add the following to your .htaccess code:
RewriteEngine On RewriteCond %{HTTPS} !^on$ RewriteRule (.*) https://yourdomain/$1 [R,L]
Create a Wildcard Subdomain Redirect
Add the following to your .htaccess code:
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.mydomain\.dk$ [NC] RewriteCond %{HTTP_HOST} ^(.*)\.mydomain.dk$ [NC] RewriteRule ^(.*)$ http://mydomain.dk/ [P,L,QSA]
Create an IP-based Whitelist to a WordPress login page
Create a file called '.htaccess' in the same directory as the 'wp-login.php' page. Add the following code:
Order Allow,Deny Allow from 111.222.333.444
Replace 111.222.333.444 with your IP (you can find your IP at http://hostek.com/IP. Note that you can add multiple IP addresses like so:
Order Allow,Deny Allow from 111.222.333.444 Allow from 111.222.333.444 Allow from 111.222.333.444 Allow from 111.222.333.444