?
Solved

RewriteRule question

Posted on 2011-03-10
4
Medium Priority
?
214 Views
Last Modified: 2012-05-11
Right now my code looks like this:

*
RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^example-for-([0-9]+)-([0-9]+)?$        example.php?id1=$1&id2=$2   [NC,L]  
*

It works fine, my question is, right now you can type either url in and it will go to either one. Is there a way to make it so if somebody types in "example.php?id1=$1&id2=$2" it automatically redirects them to "example-for-([0-9]+)-([0-9]+)?$"?
0
Comment
Question by:anotherdotcommer
[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
4 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 35105637
Try something like this:

RewriteCond %{QUERY_STRING} id1=([0-9]+)
RewriteCond %{QUERY_STRING} id2=([0-9]+)
RewriteRule example.php example-for-%1-%2 [R]

Open in new window


http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
0
 

Author Comment

by:anotherdotcommer
ID: 35866456
I've requested that this question be deleted for the following reason:

No best answer.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 35866457
My example is a valid solution.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 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