Solved

Need help on Apache URL rewrite

Posted on 2006-11-10
2
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

623 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