Truncating Page URLs

Hi there,

I’m just working on a new design for my portfolio and would like some advice on how to remove the file extension from my pages (e.g. .asp, .html etc) and replace them with something more SEO-friendly (e.g. /portfolio.html to /website-design-portfolio).

If anyone has any ideas how I could go about doing this I’d really appreciate it!



[font=verdana]If you add the line

Options +MultiViews

to your .htaccess file, it will allow you to miss off file extensions. So if you ask for and there’s a page at it will redirect you to that. (If you have multiple files with the same name but different filetypes then this can go horribly pear-shaped and you would need to use a more rigorous re-write approach.)

In terms of renaming the files, why would you want to replace a name that is short, easy to remember, easy to type and nicely tweetable, with one that is none of those? I really don’t get this current fetish for cramming half a paragraph into the URL, and I’ve not seen any real evidence that it makes a tangible difference to performance in search engines.

But if you really feel you have to go down that route, you’ll need to set up individual re-writes for each file. If you use a CMS then it might have an option to do that, but otherwise it’s pretty straightforward. If you’re keeping the file name as it is now and just using the long name as an alias then for each page, just add a line like this to your .htaccess file:

Redirect 301 /fancy-long-new-url

or if you’re going to actually rename the file to the new name you need it the other way round:

Redirect 301 /oldurl.php

Note that you need the full URL including http and domain name for the “to” part of the redirect, but not the “from” part.[/font]


I consider MultiViews to be a major problem because it can pick a part of a filename out of a path and deliver unanticipated content. From, there can be other problems (AddType and DirectoryIndex):


You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.