Skip to main content
added 55 characters in body
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

In addition to Evgeniy's answer which handles the situation when the /index.html URL is inadvertently exposed (and indexed) and needs to be canonicalised, you should also ensure that you always link to the bare URL, ie. / and not /index.html. The end user should never see "index.html" anywhere.

For / (the bare directory) to work (to silently request index.html) you need to ensure that mod_dir is enabled (it is be default) and that the DirectoryIndex is set appropriately (default is index.html). For example:

DirectoryIndex index.html index.php

The DirectoryIndex directive tells Apache which file to serve when a filesystem directory (eg. example.com/ or example.com/directory/, etc.) has been requested. In this case it will look for index.html and if not found will check for index.php, etc. in the respective directory.

To also help the search engines to always index (or at least, return in the SERPs) the correct/canonical URL you can include a rel="canonical" element in the head section of your pages pointing to the correct URL. For example:

<link rel="canonical" href="http://example.com/">

And lastly, setup an external redirect to correct any index.html URLs that have already been indexed. (See Evgeniy's answer.)

In addition to Evgeniy's answer which handles the situation when the /index.html URL is inadvertently exposed (and indexed) and needs to be canonicalised, you should also ensure that you always link to the bare URL, ie. / and not /index.html.

For / (the bare directory) to work (to silently request index.html) you need to ensure that mod_dir is enabled (it is be default) and that the DirectoryIndex is set appropriately (default is index.html). For example:

DirectoryIndex index.html index.php

The DirectoryIndex directive tells Apache which file to serve when a filesystem directory (eg. example.com/ or example.com/directory/, etc.) has been requested. In this case it will look for index.html and if not found will check for index.php, etc. in the respective directory.

To also help the search engines to always index (or at least, return in the SERPs) the correct/canonical URL you can include a rel="canonical" element in the head section of your pages pointing to the correct URL. For example:

<link rel="canonical" href="http://example.com/">

And lastly, setup an external redirect to correct any index.html URLs that have already been indexed. (See Evgeniy's answer.)

In addition to Evgeniy's answer which handles the situation when the /index.html URL is inadvertently exposed (and indexed) and needs to be canonicalised, you should also ensure that you always link to the bare URL, ie. / and not /index.html. The end user should never see "index.html" anywhere.

For / (the bare directory) to work (to silently request index.html) you need to ensure that mod_dir is enabled (it is be default) and that the DirectoryIndex is set appropriately (default is index.html). For example:

DirectoryIndex index.html index.php

The DirectoryIndex directive tells Apache which file to serve when a filesystem directory (eg. example.com/ or example.com/directory/, etc.) has been requested. In this case it will look for index.html and if not found will check for index.php, etc. in the respective directory.

To also help the search engines to always index (or at least, return in the SERPs) the correct/canonical URL you can include a rel="canonical" element in the head section of your pages pointing to the correct URL. For example:

<link rel="canonical" href="http://example.com/">

And lastly, setup an external redirect to correct any index.html URLs that have already been indexed. (See Evgeniy's answer.)

Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

In addition to Evgeniy's answer which handles the situation when the /index.html URL is inadvertently exposed (and indexed) and needs to be canonicalised, you should also ensure that you always link to the bare URL, ie. / and not /index.html.

For / (the bare directory) to work (to silently request index.html) you need to ensure that mod_dir is enabled (it is be default) and that the DirectoryIndex is set appropriately (default is index.html). For example:

DirectoryIndex index.html index.php

The DirectoryIndex directive tells Apache which file to serve when a filesystem directory (eg. example.com/ or example.com/directory/, etc.) has been requested. In this case it will look for index.html and if not found will check for index.php, etc. in the respective directory.

To also help the search engines to always index (or at least, return in the SERPs) the correct/canonical URL you can include a rel="canonical" element in the head section of your pages pointing to the correct URL. For example:

<link rel="canonical" href="http://example.com/">

And lastly, setup an external redirect to correct any index.html URLs that have already been indexed. (See Evgeniy's answer.)