Solved

RewriteRule question

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

777 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