Fix pretty url style paths.

Ignore the basename if the page is an index page, preserve it if it's just an
html page and use the full path in every other case.