Search code examples
urlseospecial-charactersfacelets

Special character in url like (å æ ø) results in a 404 error Facelets?


I am unable to navigate to a page that it is correctly configured in the facelets config file as follows:

<navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
            <from-outcome>nyhet</from-outcome>
            <to-view-id>/Bughaugane-område-Nyheiter.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

Clicking on an anchor that references url causes a 404 error:

<li><a jsfc="h:link" outcome="nyhet">#{global.nyhet}</a></li>

A similar issue is experienced with usage of special chars in file names. Is this a Facelets or just an HTML issue? How can I fix this ( I know the chars are to blame, because removing them resolves the issue).

I need to keep the words with weird chars for SEO.


Solution

  • As you're using Tomcat, you need to tell it to interpret URLs using UTF-8. Open /conf/server.xml, locate the <Connector> element which is been used by your webapp and add the URIEncoding attribute with value of UTF-8.

    <Connector ... URIEncoding="UTF-8">
    

    This way you don't need to manually change the URLs with special characters.