Solved

Need help on Apache URL rewrite

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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). #…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 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

12 Experts available now in Live!

Get 1:1 Help Now