We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8343
    • 6 Posts
    Hi, I’m running into this problem about my urls:
    Currently I am using user friendly aliases:
    So, in the resource alias field I have, for instance: contact
    And the full url address will be shown on the browser as http://www.example.com/contact.html
    I wanted to create a special page with an address like this: http://www.example.com/special
    But if I assign "special" as a url alias, then the rewrite rule will be http://www.example.com/special.html
    I don’t mind if that is the case, as long as when somebody types in the browser: www.example.com/special the user will be redirected to the right resource.
    How is that possible? I couldn’t see in the friendly url setting to not append ".html", I thought I had seen this option, but I can’t find it. On the other hand, I wouldn’t like to break other urls that has ".html" at the end.
    What should I do?
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      You could set up 2 different HTML "Content Types" under System --> Content Types. This is how you assign extensions, basically... it’s a bit silly for your particular problem, but what you could do is make a copy of the basic HTML content type so you have 2 variations: one that uses the .html extension, and one that uses no extension. Then when you edit your page, go to the "Page Settings" tab and select which content type you’d prefer: the regular HTML (with the .html extension) or the HTML type without the extension.

      You could accomplish something similar using .htaccess rewrites or the FirstChildRedirect Snippets, but I think the above is probably less prone to error.
        • 33968
        • 863 Posts
        Or you could just remove the .html extension entirely - it’s not necessary - and just have nice clean urls wink

        http://www.example.com/contact
        http://www.example.com/special
          • 9102 ☆ A M B ☆
          • 318 Posts
          Or you could choose "Freeze URI" on the Page Settings tab and just set the URI to whatever you want it to be, if it’s just this one resource.

          I have quite a few resources like this on one site, and I usually do this with .htaccess rules and it works fine, but messing with .htaccess is indeed error intolerant.

          Edit to add: Lucas, I have to disagree with you on this one, in principle one should distinguish between files and directories clearly by using a file extension. Admittedly you don’t have to have it, but I would consider it "cleaner" to use a proper extension.

          This is similar to the www vs non-www debate - personally I prefer www as it is technically a subdomain with the original meaning of "the subdomain that serves web content" as opposed to other subdomains that might serve other content such as ftp or mail. Again, not strictly necessary, but it seems polite to tell your user agents what they can expect to find at a URL by specifying it properly.
            • 33968
            • 863 Posts
            Quote from: fr33jung at Aug 03, 2011, 02:17 AM

            Edit to add: Lucas, I have to disagree with you on this one, in principle one should distinguish between files and directories clearly by using a file extension. Admittedly you don’t have to have it, but I would consider it "cleaner" to use a proper extension.
            This would make sense for a file system, but we are talking database-driven web pages here. There are no files or directories, only aliases or ’virtual locations’ that ultimately point to just one file: index.php

            HTTP headers provide all the information about a page’s content type and as far as I know the extension is not used at all by the browser.

            Without an extension, urls are:
            - shorter, easier to remember and enter correctly
            - aesthetically pleasing
            - SEO friendly (keyword density is not really a ranking factor these days, but it all helps)
            - arguably more secure as you are not broadcasting the language your site is written in

            And best of all, they avoid duplicate page issues such as the original poster described above wink

            Those are my thoughts, and the reason why I will avoid extensions wherever possible for html files in future.

            Note: I’m referring to dynamic web pages here - it’s important to keep file extensions in place for legitimate files such as images and pdf documents.