title: Removing /faces/ from URL in JSF applications
body: <p>I have made website using JSF 2.0</p>
  
  <p>All links goes as below.</p>
  
  <pre><code>http://www.mywebsite.com/faces/index.xhtml
  </code></pre>
  
  <p>What I want is remove /faces/, so that final url would be as below.</p>
  
  <pre><code>http://www.mywebsite.com/index.xhtml
  </code></pre>
  
  <p>Note: I want to achieve this while passing parameters.</p>
  
  <p>This question is related to my <a href="https://stackoverflow.com/questions/27449660/making-short-url-for-doctor-profile">previous question</a></p>
  
  <p>What I tried is changing filter criteria for my new filter</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;UrlRewrite&lt;/filter-name&gt;
      &lt;filter-class&gt;com.lab.filter.UrlRewriteFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;UrlRewrite&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p><strong>TO</strong></p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;UrlRewrite&lt;/filter-name&gt;
      &lt;filter-class&gt;com.lab.filter.UrlRewriteFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;UrlRewrite&lt;/filter-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt; // here made change from /* to /
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>But it was giving errors. No web page is showing.</p>
  
  <p>What I want to achieve from previous is mywebsite.com/faces/dr.rajesh to mywebsite.com/dr.rajesh</p>
  
  <hr>
  
  <p>Full WEB-INF as below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
          &lt;param-value&gt;Production&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;faces/index.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;restrict&lt;/filter-name&gt;
          &lt;filter-class&gt;com.lab.filter.MyFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;restrict&lt;/filter-name&gt;
          &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.apache.myfaces.webapp.filter.ExtensionsFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;/filter-mapping&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;primefaces.THEME&lt;/param-name&gt;
          &lt;param-value&gt;none&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;com.sun.faces.enableRestoreView11Compatibility&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;UrlRewrite&lt;/filter-name&gt;
          &lt;filter-class&gt;com.lab.filter.UrlRewriteFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;UrlRewrite&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>