title: Allow only access to a specific mod_rewrite generated URL, deny all other http requests
body: <p>I have a REST API being served at by apache2 at www.mysite.com.</p>
  
  <p>the rest api is accessible at www.mysite.com/rest/...</p>
  
  <p>However there is no folder named /rest on the box, its all happening by rewrite rules.</p>
  
  <p>How can achieve the following using the .htaccess file:</p>
  
  <p>1) allow access to All requests coming to www.mysite.com/rest/... (i.e. any request, as long as it is sub to the virtual folder /rest)</p>
  
  <p>2) allow any other request ONLY from a specific IP address e.g. fictitious IP 123.45.67.89; for all other IP addresses, deny</p>
  
  <p>Reason for this is I do not want anyone even as much as landing on the admin page which is at www.mysite.com.</p>
  
  <p>Thank you</p>
  
  <p>Content of httpd.conf is as follows:</p>
  
  <pre><code>&lt;Directory "/opt/bitnami/apps/myapp/htdocs/web"&gt;
  Options -Indexes +FollowSymLinks -MultiViews
  AllowOverride None
  
  &lt;IfVersion &lt; 2.3 &gt;
   Order allow,deny
   Allow from All
  &lt;/IfVersion&gt;
  &lt;IfVersion &gt;= 2.3&gt;
   Require all granted
  &lt;/IfVersion&gt;
                     &lt;IfModule pagespeed_module&gt;
                     ModPagespeedDisallow "*"
                     &lt;/IfModule&gt;
  RewriteEngine on
  RewriteBase /
  
  #   Force login to be SSL
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^(.+)\.cloud\.myapp\.com$ [NC]
  RewriteRule ^/?web/login/?(.*) https://%{SERVER_NAME}/web/login/$1 [R,L]
  
  # if ack directory or a file exists, use it directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # otherwise forward it to index.php
  RewriteRule ^.*$ /index.php [L]
  ### END: .htaccess inline ###
  
  &lt;LimitExcept GET HEAD PUT DELETE PATCH POST&gt;
      Allow from all
  &lt;/LimitExcept&gt;
  
  &lt;IfDefine USE_PHP_FPM&gt;
     RewriteEngine On
     RewriteOptions Inherit
  
     RewriteRule ^(.*\.php(/.*)?)$ fcgi://uds=%2fopt%2fbitnami%2fphp%2fvar%2frun%2fmyapp.sock/%{REQUEST_FILENAME} [P,L]
  &lt;/IfDefine&gt;
  </code></pre>
  
  <p></p>
  
  <p>Include "/opt/bitnami/apps/myapp/conf/htaccess.conf"</p>