title: JSF and PrettyFaces - How to restrict direct xhtml requests
body: <p>I'm new to JSF and PrettyFaces. So by now i found out that i can configure PrettyFaces to "forward" the request to the right .xhtml file. The problem is, that i (or a user, in case he knows my folder structure) also can request the file. This is my sample:</p>
  
  <p>Files:
  webbapp/mypage.xhtml</p>
  
  <p>I added the following lines to pretty-config.xml:</p>
  
  <pre><code>&lt;url-mapping id="myPageId"&gt;
      &lt;pattern value="/prettyurltomypage" /&gt;
      &lt;view-id value="/mypage.xhtml" /&gt; 
  &lt;/url-mapping&gt;
  </code></pre>
  
  <p>The PrettyFaces Filter is configured to intercept on "/<em>". The Faces Front Controller is configured to process all "</em>.xhtml" requests. When i request...</p>
  
  <pre><code>http://localhost:8080/myapp/prettyurltomypage
  </code></pre>
  
  <p>...evrything is fine. My problem is, that i can also request...</p>
  
  <pre><code>http://localhost:8080/myapp/mypage.xhtml
  </code></pre>
  
  <p>How can i restrict the .xhtml requests? My goal is to make jsf/server deliver the default 404 page.</p>
  
  <p>My solution (so far) was to define a rewrite rule in pretty-config.xml:</p>
  
  <pre><code>&lt;rewrite match="/mypage.xhtml" substitute="/prettyurltomypage" redirect="301" /&gt;
  </code></pre>
  
  <p>Is there any other (smarter) way?</p>