Solved

Need help on Apache URL rewrite

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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 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 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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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