Note that there are some explanatory texts on larger screens.

plurals
  1. PORewriteCond Check if file exists in a subdirectory
    primarykey
    data
    text
    <p>I'm using <a href="http://iirf.codeplex.com/documentation" rel="nofollow noreferrer">Iirf v2.0</a>.</p> <p>I have the following directory structure:</p> <pre><code>/ /library /library/index.php /webroot /webroot/images /Iirf.ini </code></pre> <p>Where I have a library folder which contains my application, a webroot folder (which contains images, stylesheets etc) and an Iirf.ini config file.</p> <p>I'm wanting to redirect all requests to /library/index.php <strong>if</strong> the file doesn't exist under webroot.</p> <p>eg:</p> <pre><code>Request Response /images/blah.png -&gt; /webroot/images/blah.png /news -&gt; /library/index.php </code></pre> <p>My Iirf.ini config has:</p> <pre><code>RewriteEngine ON RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /library/index.php [L] </code></pre> <p>Which redirects everything to <code>/library/index.php</code> but I'm having trouble working out how to check if the <code>REQUEST_FILENAME</code> exists under webroot.</p> <p>I've looked at <a href="https://stackoverflow.com/questions/873022/using-altered-request-uri-in-rewritecond-file-exists-check">this question</a> but I don't have access to <code>DOCUMENT_ROOT</code>. It gives me the following (taken from the log):</p> <pre><code>Thu Jul 15 11:46:21 - 760 - ReplaceServerVariables: VariableName='REQUEST_FILENAME' Value='C:\web\favicon.ico' Thu Jul 15 11:46:21 - 760 - ReplaceServerVariables: in='%{DOCUMENT_ROOT}/webroot/%{REQUEST_FILENAME}' out='DOCUMENT_ROOT/webroot/C:\web\favicon.ico' </code></pre> <p>Any help would be greatly appreciated.</p> <p>--- <strong>EDIT</strong> --</p> <p>I've updated my config after more reading and the suggestions of Tim to be:</p> <pre><code>RewriteCond $0 !^/webroot RewriteRule ^.*$ /webroot$0 [I] RewriteCond $0 !-f RewriteRule ^/webroot/(.*)$ /library/index.php [I,L,QSA] </code></pre> <p>And it passes to <code>/library/index.php</code> correctly but it still doesn't check for an existing file (even though it seems to say that it does).</p> <pre><code>Thu Jul 15 14:47:30 - 3444 - EvalCondition: checking '/webroot/images/buttons/submit.gif' against pattern '!-f' Thu Jul 15 14:47:30 - 3444 - EvalCondition: cond-&gt;SpecialConditionType= 'f' Thu Jul 15 14:47:30 - 3444 - EvalCondition: Special: it is not a file </code></pre> <p>I think I'm going to have to contact the author of the Filter.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload