Solved

Apache rewrite

Posted on 2015-02-08
4
89 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
[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

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
setting up tomcat for external access 4 82
tomcat LDAP authentication issue 3 224
Hosting application in Apache and Tomcat 1 120
More Than One Website On Same DMZ Server 3 92
As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…

735 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