This can easily be solved by just inserting a single line of Apache Rewrite code. First you need to identify how many of RewriteRule and RewriteCond lines are currently in your htaccess file (let's name it RULECOUNT). Note that these lines are typically grouped together which this solution is perfectly suitable. Next thing you do is place the following code right before these lines. For the purpose of this example, let's assume you have four lines of rules in your htaccess file (RULECOUNT = 4).
RewriteRule ^downloads/ - [S=RULECOUNT]
What this thing does is simply skip the rest of the Conditions and Rules if the URI is trying to invoke our Downloads directory or any of the files within it.
Example URI:
http://yoursite.com/downloads/
http://yoursite.com/downloads/markuzwebtips.pdf
http://yoursite.com/downloads/markuzwebtips.pdf
Here's a working example code:
RewriteRule ^downloads/ - [S=4]
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)(\.txt)$
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)(\.txt)$
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
I thought of posting this topic because one of the sites we're maintaining is integrated into Silverstripe. And by Silverstripe's default setting, all of its URI goes through rewrite rules. This solution simply puts an exemption on a specific subdirectory.
Related Posts:
1 comments :
Thanks, just what I needed.
Post a Comment
Hi there! Please leave your message here. Also, I may not be able to respond to your query right away. So please bear with me. Thanks. :)