Solved

Apache rewrite

Posted on 2015-02-08
4
86 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
ID: 40598394
Why not do this programmatically when you handle the query string parsing?
0
 

Author Comment

by:yelbow
ID: 40598423
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
ID: 40598976
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 17

Assisted Solution

by:Lucas Bishop
Lucas Bishop earned 250 total points
ID: 40607441
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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