Solved

RewriteRule question

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

726 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