Solved

Apache Look in sub directory and rewrite only if file exists

Posted on 2013-06-12
1
202 Views
Last Modified: 2013-06-13
Using Apache's mod_rewrite in .htaccess, how can I detect if the destination file exsists and only perform the rewrite if it does exsist?

This does not work:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule day/(.*) /dynamic/image/cache/$1 [L]

Open in new window

0
Comment
Question by:hankknight
1 Comment
 
LVL 20

Accepted Solution

by:
edster9999 earned 500 total points
ID: 39243061
Something like ;

RewriteCond $1 !^dynamic/image/cache/
RewriteCond /dynamic/image/cache/$1 -f [OR]
RewriteCond /dynamic/image/cache/$1 -d
RewriteRule ^(.*)$ /dynamic/image/cache/$1 [L]

Open in new window

0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question