Solved

Apache Look in sub directory and rewrite only if file exists

Posted on 2013-06-12
1
200 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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). #…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now