This is a mirror of official site: http://jasper-net.blogspot.com/

17 Useful Htaccess Tricks and Tips

| Sunday, November 7, 2010
Introduction

Some people might not aware of the power of htaccess, I have 17 htaccess methods in this article which I have used or tested it before, and I think some of them are essential tricks and tips to protect your webserver against malicious attacks and other would able to perform simple tasks efficiently such as redirection and web server optimization.

Last but not least, if you have been looking for web hosting services, you might want to have a look at this unlimited web hosting. :)

General

The following htaccess will able to help you to achieve simple task such as redirection and web server optimization.

1. Set Timezone

Sometimes, when you using date or mktime function in php, it will show you a funny message regarding timezone. This is one of the way to solve it. Set timezone for your server. A list of supported timezone can be found here

SetEnv TZ Australia/Melbourne  

2. SEO Friendly 301 Permanent Redirects

Why it's SEO friendly? Nowadays, some modern serach engine has the capability to detect 301 Permanent Redirects and update its existing record.

Redirect 301 http://www.queness.com/home http://www.queness.com/  

3. Skip the download dialogue

Usually when you try to download something from a web server you get a request asking whether you want to save the file or open it. To avoid that you can use the below code on your .htaccess file

AddType application/octet-stream .pdf  
AddType application/octet-stream .zip  
AddType application/octet-stream .mov  

4. Skip www

One of the SEO guideline is, make sure there is only one URL pointing to your website. Therefore, you will need this to redirect all www traffic to non-ww, or the other way around.

RewriteEngine On  
RewriteBase /  
RewriteCond %{HTTP_HOST} ^www.queness.com [NC]  
RewriteRule ^(.*)$ http://queness.com/$1 [L,R=301]

Read more: Queness

Posted via email from .NET Info

0 comments: