I have to restrict access to particular URL, e.g. http://mydomain.com/this/is/the/url on my small webserver using Fundamental Authentication through Apache. Every other URL ought to be freely accessible. I've come across that you could add specific rules to files using:

<Files "mypage.html">
  Require valid-user
</Files>

My issue is that demands are routed to remotes using mod-rewrite therefore i don't believe will be able to restrict access in line with the file. Any ideas could be most useful!

You are able to safeguard the whole directory by putting a separate .htaccess for the reason that directory. This tutorial describes it much better than I possibly could:

http://www.addedbytes.com/lab/password-protect-a-directory-with-htaccess/

I am unsure if the worksOrassist, however, you could specify something inside your application web.xml.

  <security-constraint>
    <display-name>Public access</display-name>
    <web-resource-collection>
      <web-resource-name>PublicPages</web-resource-name>
      <description>Public</description>
      <url-pattern>/servlet/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  <security-constraint>
    <display-name>Secured access</display-name>
    <web-resource-collection>
      <web-resource-name>SecuredPages</web-resource-name>
      <description>Secured pages</description>
      <url-pattern>/services/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <description>General Access</description>
      <role-name>*</role-name>
    </auth-constraint>
    <user-data-constraint>
      <description>SSL not required</description>
      <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>SecurePages</realm-name>
  </login-config>
  <security-role>
    <description>General Access</description>
    <role-name>*</role-name>
  </security-role>