Solved

Need help on Apache URL rewrite

Posted on 2006-11-10
2
203 Views
Last Modified: 2010-03-04
I am considering to write some rewrite rules in a .htaccess file that meets the following conditions:

when user requests an url like :  http://localhost/img.php?w=12&h=21&d=5
apache would check whether  the file named "images/img_12_21_5.jpg" exists, if yes, just rediect to the file; however if no, the browser will redirect to a file named "images/blank.gif";

Can it be implemented just using apache rewrite rules? Thank you.
0
Comment
Question by:klemperer
  • 2
2 Comments
 
LVL 43

Accepted Solution

by:
ravenpl earned 125 total points
ID: 17920674
RewriteEngine On
RewriteCond %{QUERY_STRING} ^w=12&h=21&d=5$ //match exatly
RewriteRule ^img.php$ /images/img_12_21_5.jpg //rewrite to the new file
RewriteCond %{REQUEST_FILENAME} ! -s //not exist or empty
RewriteRule ^images/.*\.jpg /images/blank.jpg [L] //don't try next rewrites, redirect any non existent images/*.jpg

0
 
LVL 43

Expert Comment

by:ravenpl
ID: 17921150
And why B?
I can help if something wrong here.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

777 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