Some advantages of .htaccess file
February 17, 2010 | Posted by Supachet Kotsrimuang | 1 CommentToday, I would like to talk about one file name .htaccess that I think it is very useful. This file can do a lot of things useful for your website management or even your online marketing like SEO. In order to create this file, you just open any text editors you are familiar with like EditPlus, Dreamweaver or even WordPad or NotePad and then name the file as .htaccess. It seems this file does not have the filename and it has only extension as htaccess. Then, let see what we can add to this file to help you do these following things.
Custom 404 : 404 is the page normally coming up when users try to visit any non existing pages. The sample of default 404 page is below.

If you want to have your own 404 page like the one we have below you can do that by

- creating your 404 page and uploading to your server
- Adding this line in .htaccess files
ErrorDocument 404 (The location of your 404 page)
- Uploading .htaccess to the root level of your server
Then once users visit any of your non existing web pages, your custom 404 page will be shown.
301 Redirect : This is the method for redirecting old webpages to the new ones with the value that the old web pages have such as the rankings in search engines. Also, it can prevent your website to have diffetent URLs, one with www and the other without www (i.e. http://www.aaa.com and http://aaa.com). What you need to do is adding these lines into your .htaccess file
rewritecond %{http_host} ^aaa.com [nc]
rewriterule ^(.*)$ http://www.aaa.com/$1 [r=301,nc]
This will redirect http://aaa.com to http://www.aaa.com
Rewrite URL : As you may know that search engines normally do not like the dynamic urls that can be mostly found in EC sites or sites created by CMS like Joomla or PHPNuke. In order to make your URLs static, you have to specify the rules in .htaccess file. This is the sample
RewriteRule dvr/dvr-capture-card\.html$ products_detail.php?id=12
If you add the line above in .htaccess file, it will convert
http://www.aaa.com/products_detail.php?id=12 to
http://www.aaa.com/dvr/dvr-capture-card.html
However, .htaccess basically works with the websites run by Apache Web Server. Therefore, if you use something else as a Web Server likw IIS, you may need different ways to do the things mentioned here.
Category : Online Marketing
Спасибо…
Хм..…