Solved

Apache Look in sub directory and rewrite only if file exists

Posted on 2013-06-12
1
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache web application(s) as Service Provider - ADFS 2.0 as IDP 4 146
ProxyPass - Problem 5 245
instanceof  operator in java 26 114
AWS EC2 & RDS Instance 5 74
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…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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