Htaccess

Htaccess

From ThaiiS Note (Wiki)

Jump to: navigation, search

Why should you do this?

If you require people to login to your site, you probably give them a cookie so they don’t have to login each time. But that cookie is only good for one or the other URL, not both. So if somebody logs in using http://yourdomain.com/ and comes back later using http://www.yourdomain.com/, they’ll be forced to login again, even though a cookie already exists for them using the other version.

Also, forcing one URL variety over the other ensures that you won’t be double indexed or receive split page ranks in the search engines. While Google does a pretty good job on their end of preventing this, it’s possible that you could have two distinct page rank values for each version of the web page, even though they are 100% identical in content, but only differing in the presence of “www” in the URL.

How do you do it?

It’s simple really. Just add the following code to your .htaccess file in the highest folder of your web directory and yor visitors will be forced to use the www version.

Contents

Redirect yourdomain.com to www.yourdomain.com

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


Redirect www.yourdomain.com to yourdomain.com

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

View all File in Directory Work on win host

Options All Indexes
IndexOptions FancyIndexing

work on godaddy shareed host

Options +Indexes

Change your default directory page

specify a file that is to be loaded as your default page whenever a directory or url request comes in, that does not specify a specific page. Tired of having yoursite.com/index.html come up when you go to yoursite.com? Want to change it to be yoursite.com/cool.html
DirectoryIndex cool.html

This would cause filename.html to be treated as your default page, or default directory page. You can also append other filenames to it. You may want to have certain directories use a script as a default page.

DirectoryIndex index.html index.php index.pl default.htm


generator

http://www.blogsdna.com/754/top-5-online-htaccess-mod-rewrite-rules-generator-website-blogs.htm

Force Files to Download (Not Open in Browser)

put in .htaccess

AddType application/octet-stream .csv
AddType application/octet-stream .xls
AddType application/octet-stream .doc
AddType application/octet-stream .avi
AddType application/octet-stream .mpg
AddType application/octet-stream .mov
AddType application/octet-stream .pdf