Skip to content Skip to sidebar Skip to footer

Is This Good Link Practice?

Is this bad practise in any way? The folder structure (every html page has filename index.html located in a subfolder): root-folder (index.html) subpage1 (index.html) subpage2

Solution 1:

The problem I have with an approach like this is that all your files are called 'index.html' and it's difficult to tell in your editor which is which. Also you have the problem of opening/closing each folder to navigate around and make edits, yuck.

What you can do to get the url's that you want is to use something like mod_rewrite to turn those nice-urls into the real filenames.

Add something like this for your .htaccess file:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]

And in all your pages you'll be able to have links like the last example:

<a href="/">index</a>
<a href="/subpage1">subpage1</a>
<a href="/subpage2">subpage2</a>
<a href="/subpage3">subpage3</a>

Solution 2:

The cleanest way, like you said, is to use absolute paths, as in your second example. I would avoid using relative paths for the purpose that you have described.


Post a Comment for "Is This Good Link Practice?"