Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Apache Look in sub directory and rewrite only if file exists

Posted on 2013-06-12
1
Medium Priority
?
217 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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

927 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