Solved

Apache Look in sub directory and rewrite only if file exists

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
URL rewriting - LAMP 7 46
Website being blocked? 3 129
Zipping many files freeze my whole server through php 5 68
Apache,  not running php on top level 14 71
In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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