Solved

RewriteRule question

Posted on 2011-03-10
4
208 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 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

14 Experts available now in Live!

Get 1:1 Help Now