Hiding the .html extension in the url

My client wants all the pages in his site not to show the .html in the top url address bar. ie:

www.his-site/aboutme.html

to show as:
www.his-site/aboutme

I think this is partly so he can tell his customers to go to: www.his-site/aboutme nice and simple, right?

I have tried to do this by creating sub-folders in Freeway called ‘home’, ‘about’, ‘news’ etc then naming each page index.html and placing each one inside the relevant sub-folder.

The problem is that the css menu on each page still points to www.his-site/news/index.html

I could change each link in the css menu to the absolute url of http://www.his-site/news

…but then the current page doesn’t show as active in the css menu unless I individually add the [class: fwCurrent] in ‘Extended’ and therefore break the menu’s link to the master page.

So, after all that! Does anyone know a way to hide the .html extension without the above hassles?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You need to create an .htaccess file. There are numerous how-to posts
on this list and plenty more examples online (Google). If you still
can’t find what you need post back.

Todd


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Todd, thank you so much for responding. This seems like a good article: .newmediarts | ::: Hide file extensions in URLs with .htaccess files
I’ll give it a try and report back.

Thanks again.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Well it ‘half’ worked!

Inserting the code (below) into the .htaccess file does mean you can go to:

www.his-site/aboutme and view www.his-site/aboutme.php

But it doesn’t stop the .php or .htm extension showing if you use the navigation menu on the site.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

Do you know of any way to hide the file extension when using the on-site navigation?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

That’s going to require some more rewrite-fu, but likely is going to be a colossal hassle in practice, possibly leading to infinite recursion and hanging your server.

Freeway will always write correct URLs to the pages. Unless you post-process your site using a tool like BBEdit to do batch search-and-replace (and repeat this step after every design change) you won’t get tail-less URLs.

Another approach would be to change every automatic link in your site to a manual “external” link. So where you have chosen the page Widgets from the list in Freeway, and Freeway has written a proper URL to widgets.html, you would have to change that to simply widgets. Repeat for every link in the site. The benefit to that would be that you would not need to post-process the HTML after design changes, but the down-side would be that you must figure out the correct relative URL to your target page, so you’ll have to become familiar with the various tricks for traversing directory structures, like ../../foo/bar/baz.html to move up and over, and maintain a good mental model of where each page is in the overall hierarchy. This is the part of the job that I’m usually happy to cede to Freeway – it’s just donkey-work.

Seriously, in the final estimate, you’re being asked to nearly double your effort for limited or no return. If your client is paying you double for this “tweak” (which is not a tweak, not by any stretch) then fine. Take the money and grumble. But if they expect this to be thrown in, push back. Argue that this is not how the Web works. Point out that extensions in filenames are a good thing: they reduce the amount of work that the server is expected to do on every request and therefore speed up the site. (This is actually true, if such a small amount that it would be difficult to measure on all but the largest and highest-traffic sites.)

Any sites your customer may be comparing his site to which feature these types of URLs are actually content-managed sites based on a CMS, or Web applications built in Ruby on Rails or the like. Those aren’t actually URLs at all, but rather a set of instructions to the application server, passing a set of variables into a computer program which locates and composites and serves the resulting dynamic content to the browser as if it was a normal “real” HTML page.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walter, as always, I really appreciate your feedback and advice.

Many thanks to you and indeed Todd!

Simon.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On Feb 16, 2011, at 9:09 AM, Sly wrote:

Walter, as always, I really appreciate your feedback and advice.

Many thanks to you and indeed Todd!

You’re welcome, Simon.

Todd


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options