Trailing Slash – Creating Correct Link Structure

When building your web site it’s important to incorporate the correct link structure from the beginning. This will save a lot of headaches in the future should you decide to expand your web site.

1. Should you link to your home page with or without a trailing slash? (without the trailing slash) (with the trailing slash)


Put the index file in the root of the domain, and call it index.html.

On all of your pages where you link to the index file, link to it using just / or and it will work fine.

If you link to index.html then if you ever change to index.php then all of your links will immediately be broken. Omit the filename
from the links!

What if your current site’s home page has no trailing slash?


If you need to redirect to and you’ve got mod_rewrite enabled on your server you can put this in your .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$$1 [R=permanent,L]

Some search engines (ie Yahoo) remove the trailing slash for some urls that end with a slash – you can force them by creating a
.htaccess file.

For a more in-depth explanation read:

How to Redirect a Web Page Using a 301 Redirect


  1. Thanks for the post. However, I think your rewrite rule will only add a trailing slash to the parent URL and not the directories.

    Please correct me if I’m wrong, but wouldn’t you want to add a trailing slash to the end of this line?

    RewriteRule ^(.*)$$1/

    That way gets a trailing slash at the end:

  2. Sick! Just received a brand-new Pearl and I can now read your weblog on my phone’s browser, it didn’t work on my aged 1.


  1. […] Trailing Slash – Creating Correct Link Structure […]

Speak Your Mind