WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  HTTPserver remove .html extension from URL

    Posted Mon January 18, 2021 11:30 AM
    Hello:

       I need to remove .html extension from de URL, now I am using this configuration

    Include conf/rewrites.txt
    Include conf/redirects.conf

    rewrite.txt
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.html [NC,L]

    redirect.conf
    Redirect 301 "/en" "/"

    This works when i put in url myweb.com/terms but when i put myweb.com/terms.html do not remove de .html extensionn also the redirects stop working

    is there a way to remove the extension in both cases?

    Thanks

    ------------------------------
    Luis Tejeda Alcolea
    ------------------------------


  • 2.  RE: HTTPserver remove .html extension from URL

    Posted Mon January 18, 2021 11:57 AM
    Hi,

    to remove .html extension i resolve it adding

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
    RewriteRule ^(.*)\.html$ $1 [R=301,L]

    But Redirect 301 "/en" "/" still failing, I think I'll have to do it with a rewrite

    Regards





    ------------------------------
    Luis Tejeda Alcolea
    ------------------------------



  • 3.  RE: HTTPserver remove .html extension from URL

    Posted Tue January 19, 2021 03:29 AM
    Could you provide more information about the naming conventions of your URL where you want to remove .html?
    Is it
    myweb.com/terms.html.de
    myweb.com/terms.de.html
    myweb.com/de/terms.html
    myweb.com/en/terms.html
    myweb.com/terms.html/de
    myweb.com/terms.html/en



    ------------------------------
    Matthias Jungbauer
    ------------------------------



  • 4.  RE: HTTPserver remove .html extension from URL

    Posted Thu January 21, 2021 04:49 AM
    Hi

    at the moment we use a file extension like

    index.html
    contact.html
    info/terms.html

    But we may use extensions with the language in the file, like:

    contact.html.de
    contact.html.es
    contact.html.en

    Regards


    ------------------------------
    Luis Tejeda Alcolea
    ------------------------------



  • 5.  RE: HTTPserver remove .html extension from URL

    Posted Fri January 22, 2021 07:17 AM
    You want to rewrite contact.html.de into contact.de ?
    And index.html into index.en ?

    ------------------------------
    Matthias Jungbauer
    ------------------------------