Solved

Need help on Apache URL rewrite

Posted on 2006-11-10
2
201 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

18 Experts available now in Live!

Get 1:1 Help Now