Solved

RewriteRule question

Posted on 2011-03-10
4
209 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
  • 2
4 Comments
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 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 50

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

863 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

26 Experts available now in Live!

Get 1:1 Help Now