In case your web hosting account is not configured to server certain mime types with the proper content type. You can change this using .htaccess file. For example if you need to configure your server to display ASX files: AddType video/x-ms-asf asf asx For windows media audio WMA AddType audio/x-ms-wma…
Continuar leyendoEtiqueta: htaccess
Enable CGI, SSI with .htaccess
As .htaccess is a powerful tool. It gives you option to change the way the webserver serves your files. On most web hosting servers you can use SSI (Server Side Includes) in shtml, or shtm files. However, you need to use SSI in your .html and htm files. There is…
Continuar leyendo301 Permanent redirects for parked domain names
If you have several domain names parked/pointed at your site it is a good idea to create permanent 301 redirect for them so for the search engines not to treat them as duplicate content. Here is a sample .htaccess that will do that: RewriteEngine on RewriteCond %{HTTP_HOST} ^parkeddomain.com$ [OR] RewriteCond…
Continuar leyendoForce SSL/https using .htaccess and mod_rewrite
Sometimes you may need to make sure that the user is browsing your site over securte connection. An easy to way to always redirect the user to secure connection (https://) can be accomplished with a .htaccess file containing the following lines: RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]…
Continuar leyendoIntroduction to mod_rewrite and some basic examples
ModRewrite is a powerful feature of the Apache web server. It provides an easy way to modify/manipulate URLs. As complicated as it sounds a regular webmaster can benefit from this feature in many way. I will list here the ones I consider most useful for the regular webmaster. Create easy…
Continuar leyendoRedirect URLs using .htaccess
Sometimes you need to redirect some URL and/or page on your site to another one. The feature is very useful if you have recently redesigned your site but you wish to keep the old addresses working for various reasons (you have links to these pages from other sites, some users…
Continuar leyendoDisable Hot-Linking of images and other files
A hot-linking is when some other site uses images hosted on yours. For example a.com has some pretty nice images. Then b.com decides that instead of hosting these images on their server, they can just link from their pages to the images hosted on site a.com. Hot-linking usually is bandwidth…
Continuar leyendoUsing .htaccess to block referrer spam
Lately referrer spam became a great annoyance for the webmasters. If you are not sure what referrer spam is you may wish to check this article: http://en.wikipedia.org/wiki/Referrer_spam To block these spam referrers you need the following lines in your .htaccess file: # set the spam_ref variable SetEnvIfNoCase Referer «^http://(www.)?some-spammer.com» spam_ref=1…
Continuar leyendoUsing .htaccess for password protecting your folders
If you need to have certain areas (folders or files) of your web site protected you can use .htaccess and .htpasswd files to enable a basic user/pass protection. The Apache web server provides a quick and easy way to protect a file or folder on your site. The password protection…
Continuar leyendoHow to change the error documents – 404 Page Not Found, etc
Using .htaccess file you can easily change the default error pages that are being served by your web server. To use .htaccess to modify your web site error pages your server needs to be configured with AllowOverride FileInfo. Most web hosting servers are configured in such a way so having…
Continuar leyendo