Solved

Apache rewrite

Posted on 2015-02-08
4
80 Views
Last Modified: 2015-02-13
A user can arrive at our site passing various variables in the URL

e.g.

http://mysite.com/?func=search&term=blah&setting=enga
or
http://mysite.com/?func=search&setting=enga&term=blah

I want to be to be able to put a rewrite rule in that will take the value of "setting" and rewrite it to be "engb" regardless of where it is in string.

What would be the rewrite rule?
0
Comment
Question by:yelbow
  • 2
4 Comments
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
Why not do this programmatically when you handle the query string parsing?
0
 

Author Comment

by:yelbow
Comment Utility
It's all embedded in third party code which we can't tinker with  - need to handle it on the way in with a mod rewrite or something.
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 250 total points
Comment Utility
You want something like this:
RewriteCond %{QUERY_STRING} (.*(?:^|&))key=val((?:&|$).*)
RewriteRule /path /path?%1other_val%2

Open in new window

Just replace "key=val" and "other_val" with their respective values.
0
 
LVL 16

Assisted Solution

by:Lucas Bishop
Lucas Bishop earned 250 total points
Comment Utility
I'm pretty sure this is the rewrite condition you want:

RewriteCond %{QUERY_STRING} ^(.+?&|)setting=[^&]*(?:&(.*)|)$ [NC]

Open in new window


Will need to dig into the correct RewriteRule to employ.

This would work if setting=enga was always at the end of the string:
RewriteCond %{QUERY_STRING} (.*(?:^|&))setting=((?:&|$).*)
RewriteRule ^ %{REQUEST_URI}?%1&setting=engb [R=301,L]

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

8 Experts available now in Live!

Get 1:1 Help Now