Here are a few tricks to .htaccess files that are good to know for SEO and security
you must start every .htaccess file with atleast this code snippet
Options +FollowSymLinks RewriteEngine on
This chunk of code allows you to use Search Engine friendly URLS
index.php?id=1 would be the same as /1/
So your link would be <a href=”/1/”> and Mod_Rewrite would then pass the “1” to the id just as though it was a query string and the spiders are none the wiser!
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?id=$1 [L] RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?id=$1&sub=$2 [L]
You only want one URL known to Google or Yahoo. the way to do this is by telling the server to redirect all non www to www's or vice versa. AND, you want ot make sure it is a permanent redirect.
RewriteCond %{http_host} ^domain-name\.com [nc]
RewriteRule ^(.*)$ http://www.domain-name.com/$1 [R=permanent,nc,L]
sometimes a page moves or is deleted but is still in the search engines or someones bookmarks. You will want to permanently redirect this old link somewhere active.
Redirect 301 /old_page.php http://www.sitename.com/index.php # or RewriteRule home/ / [R=301,L,NC]
maybe you want to redirect a whole directory if a directory name has changed…
RewriteRule ^products/old_stuff/(.*)?$ http://www.sitename.com/products/new_stuff/$1 [R=301,L]
This is server/resource intensive so use sparingly…
Sometimes you want to use PHP on a site that is HTML and for SEO value you do not want to have to rename every file. So we just frce all .html and .htm files to render as PHP!
AddType application/x-httpd-php .php .html .htm
Most servers have this option disabled, however, some do not. This could leave to a security risk. Most of the time a directory list will appear if you do not have a Default index file in it. usually this happes to image folders (i.e., www.domain-name.com/images/). In the .htaccess file you can define exactly what you want to show if anything at all.
to hide everyrthing:
IndexIgnore *
To hide images:
IndexIgnore *.gif *.jpg *.png *.swf
or what ever your file extensions are.
If you want to show directory listing, and the server has it disabled, you can add this little snippet to the .htaccess file:
Options +Indexes
.htaccess overides the Apache config parameters
As you may have guess you can use the same line to Disable Directory listings as well. Just change the + to a -
Options -Indexes
For all you fancy pants out there that like to show off their stuff, here is a little trick for your list pages. You can include a description for the directory list that will be displayed when encounter a list page. upload a file called HEADER in the directory which you will use for listing files. The contents of this file will be displayed before the list. You may also upload a footer, which is a file named README. Upload it in the same directory as the HEADER. The README file is displayed after the file listing. Rememeber, HEADER and README have No Extensions and are case Sensitive.