|
#1
|
||||
|
||||
HTACCESS
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 PHP Code:
Why it's SEO friendly? Nowadays, some modern serach engine has the capability to detect 301 Permanent Redirects and update its existing record. PHP Code:
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 PHP Code:
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. PHP Code:
Create a custom error page for each of the error codes. PHP Code:
Optimize your website loading time by compressing files into smaller size. PHP Code:
File caching is another famous approach in optimizing website loading time PHP Code:
Well, in the other hand, you can disable caching for certain file type. PHP Code:
The following htaccess code will able to enhance the security level of your webserver. Hotlinking protection is pretty useful to avoid other people using images that stored in your server. 1. Hotlinking protection with .htaccess Hate it when people stealing bandwidth from your website by using images that are hosted in your web server? Use this, you will able to prevent it from happening. PHP Code:
2. Prevent hacks If you want to increase the security level of your website, you can chuck these few lines of codes to prevent some common hacking techniques by detecting malicious URL patterns. PHP Code:
The following code will prevent user to access your .htaccess file. Also, you can block multiple file type as well. PHP Code:
You can also rename your .htaccess file name to something else to prevent access. PHP Code:
Avoid the server from displaying directory index, or the opposite. PHP Code:
You can change the default page index.html, index.php or index.htm to something else. PHP Code:
PHP Code:
This method could save your bandwidth quota by blocking certain bots or spiders from crawling your website. PHP Code:
PHP Code:
__________________
|
The Following User Says Thank You to Chez For This Useful Post: | ||
rfadown (9th October 2013)
|
#2
|
|||
|
|||
Very useful thread very good mate like it a lot
|
Tags |
htaccess |
|
|