Comment on 301 Redirect Htaccess by SEO Dave.
A 301 redirect from index.html to root won’t open your directory up for all to see as long as the DirectoryIndex is set to an index.*** file that is within that directory.
Easiest way to know is test it, does loading example.com/directory/ load the same page as example.com/directory/index.html (when there’s an index.html file in that directory).
If it does it’s set. If not set it.
DirectoryIndex can be set server side (for all sites on a server) or site/directory wide via an .htaccess file.
Put something like this at the top of your .htaccess file (if it already works it’s set server side, no need to add this):
DirectoryIndex index.html index.asp index.htm index.php
Would look for index.*** until it found one of the file types above. Order the file types in order you tend to use them as the main index file, if you only use index.php for example you’d only need:
DirectoryIndex index.php
This is the sort of code you’d add to your .htaccess file to 301 redirect /index.html to /
RewriteEngine On RewriteCond %{THE_REQUEST} /index.html [NC] RewriteRule ^(.*/)?index.html$ /$1 [R=301,L]
This will 301 redirect the index.html pages to their respective directories.
If you are finding Google is indexing index.html and you don’t want this (It won’t after adding the 301 redirect above).
1. Stop linking to example.com/index.html, make sure all links point to example.com/
2. Setup a canonical URL within the head section of your index.html file. This is a solution if you don’t have access to your .htaccess file for adding a 301 redirect, but do have access to the page code.
<link rel="canonical" href="http://www.example.com/" />
This will tell Google when it spiders www.example.com and www.example.com/index.html the correct URL is www.example.com
A canonical URL won’t redirect a browser window from /index.html to / but the link benefit/Google rankings will be redirected (like a 301 redirect without the browser redirecting).
You can set a relevant canonical URL for any page that can be loaded two or more ways. If you have dynamic pages for example that can be loaded in different ways look into canonical URLs. I use WordPress for most of my sites now and canonical URL support is built in (automated).
David Law
More Comments by SEO Dave
www/non-www Canonical SEO
301 Redirect Everything Under a Directory via .htaccess
Hmm, after rereading what I suggested the .htaccess option isn’t suitable for all directories like /wp-content/plugins/ it would 301 redirect everything under the folder to home rather than just stop users seeing the contents!
I’ve deleted that part of my earlier …
Continue Reading .htaccess File Redirect 301
www/non-www Canonical SEO
How to Hide Website Directories
Hiding a directory is a server side setting.
Assuming you run on an Apache server it’s having something like:
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch
Into your httpd.conf file for each domain on a server, this would make no directories that lack an index.html, index.php …
Continue Reading .htaccess File Redirect 301
www/non-www Canonical SEO
301 Redirect index.html
It’s the first 301 redirect example in the main 301 redirect article.
If it’s just the one webpage to redirect it’s
RewriteEngine On
Redirect 301 /index.html http://domain.com/
Add it to the root .htaccess file.
David …
Continue Reading .htaccess File Redirect 301
www/non-www Canonical SEO
301 Redirects Causing a Loop
This code:
DirectoryIndex index.html index.asp index.htm index.php
RewriteEngine On
Redirect 301 /index.html http://www.domain.com/
Will cause a loop.
You are saying via DirectoryIndex that index.html is the home page if it exists, then redirecting index.html to root which will look for index.html which will redirect to …
Continue Reading .htaccess File Redirect 301
www/non-www Canonical SEO
Canonical www/non-www Problems are SiteWide
It’s all pages of a domain, the rules above are designed for site wide 301 redirects.
David Law …
Continue Reading .htaccess File Redirect 301
www/non-www Canonical SEO
Country Domain 301 Redirects .htaccess file
Add a .htaccess file to each domain you don’t want to use to the domain you do want to use.
If you planned to use the .com you’d setup a .htaccess file with this in the other two:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.stallion-theme.org$
RewriteRule …
Continue Reading .htaccess File Redirect 301
www/non-www Canonical SEO
www to non-www 301 Sitewide Redirects
Looks like you have a 301 redirect setup so the www version of your site is redirected to the non www version.
This sort of Google search:
site:http://domain.com
Shows your site is indexed under the non www version.
Loading the www version of your …
Continue Reading .htaccess File Redirect 301
www/non-www Canonical SEO
How 301 Redirects Work
When a 301 redirect loads in a browser window you ‘see’ it redirect.
If you use the non www redirecting to the www and you loaded http://example.com/ it would immediately reload (redirect) to http://www.example.com/
If that doesn’t occur you’ve probably made a …
Continue Reading .htaccess File Redirect 301