5 Most Popular .htaccess Tips and Tricks
Monday, March 8th, 2010
There are tons of things you can do from the .htaccess file inside of your web hosting account. From redirecting the users to controlling who can get in and who can get out, it is a very useful file to have on your hosting account. To help out the new web hosting clients and to act as a reminder to the old pros around here, I thought I would go through five of the most popular .htaccess tips I know.
Redirect to a Maintenance Page
This is a great one to use if you need to make some quick web page edits, and you don’t want the public to see you edit your web site, while it is still live.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/offline.html$
RewriteRule .* /offline.html [R=307,L]
This will redirect anybody who checks out any web page on your web site to the "offline.html" file.
Force the Use of “www” in Front of a Domain Name
If you want to keep the www in front of your domain name, no matter how somebody types it in, here is the ‘bit of .htaccess magic you will need:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]
Once you have done so, both mydomain.com and www.mydomain.com will both send you to www.mydomain.com
Remove the “www” From in Front of a Domain Name
You can also force your domain to drop the www from the address when typed in, if you would rather have it the other way around. In that situation, you would need to add this to your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
This will make both mydomain.com and www.mydomain.com send you to just mydomain.com.
Manually Create Custom Error Pages
Ever check out some of those customized error pages and wonder how it could be done? Just use these snippets of .htaccess code to tell people where to look for your error pages.
ErrorDocument 400 /errors/400.html ErrorDocument 401 /errors/401.html ErrorDocument 403 /errors/403.html ErrorDocument 404 /errors/404.html ErrorDocument 500 /errors/500.html
This tells the server to look inside the “errors” folder and that specific page for each of the different error types. That is not all of the error codes, but they are the ones that will be ‘hit by your users 99 percent of the time.
Block Visitor By IP Address
Need to keep somebody from checking out your web site? This next tip will give you the ability to deny somebody based on what their IP address is:
order allow,deny deny from 123.45.6.7 deny from 012.34.5. allow from all
The above blocks access to the site from 123.45.6.7, and from any sub-domain under the IP block 012.34.5. (012.34.5.1, 012.34.5.2, 012.34.5.3, etc).
That is it for this round up of tips. For more help with the .htaccess file, and many more things you can do with your web hosting account, be sure to check out the Lunarpages Web Hosting Wiki.
© Lunarpages Web Hosting - Also, don′t forget to follow @lunarpages on Twitter!
Original post by Mitch
Socialize Yourself
Shout Box – Shout boxes are usually little boxes that life in the sidebar of a web site, and allow people to comment live on the web page with other users. One of the more popular shout box-like services I would recommend looking into would be
Often we overlook the obvious questions posted to a blog. One of the most obvious questions would be how do you subscribe an stay updated when new blog articles are posted to the Lunartics blog? Today I’ll let you know what all your options are, so that you can use the one that suits your needs the best. 







These are rough economic times, so with that said – how would you like a fool proof way to not only pay for your own hosting account, but make $87 in profits just by giving your opinion on who your friends or web site visitors should host with? I’ll let you in on this industry secret today.
Lunarpages affiliate program members get a lot of tools to use, when it comes to marketing. An affiliate advertising campaign is a great way to track the success of one particular affiliate link, in comparison with another one. At Lunarpages, you can track your own affiliate tracking campaigns with just a simple quick edit to your Lunarpages affiliate program address.
The world of reseller hosting might be a little confusing to some. However, with the right tips in hand – anybody can be a reseller hosting success. In a nut shell, reseller hosting is a form of web site hosting where the account owner has the ability to use their allotted space and bandwidth to host their own or a third parties’ web site. The account owner can sell the allotted space and bandwidth to the third party in question, and (in most cases) make a profit.