?
Solved

How do you create a conditional redirect using .htaccess based on a query string?

Posted on 2009-04-04
2
Medium Priority
?
291 Views
Last Modified: 2013-12-14
I would like to redirect using my .htaccess based on a particular query string.

if i get a URL like this with "mode=app" in the query string, i'd like to redirect to a new server:
http://stage.example.com/test/?format=json&userid=%1&version=5&mode=ffp

What is the simplest way to do this? I've experimented with redirect, RedirectMatch, RewriteCond, etc but haven't been able to do it.

THANKS!
0
Comment
Question by:Arbuckle2
[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 Comments
 

Author Comment

by:Arbuckle2
ID: 24069936
I suppose I could also do this inside a PHP file but i thought .htaccess made more sense.
0
 
LVL 27

Accepted Solution

by:
caterham_www earned 2000 total points
ID: 24070887
> redirect, RedirectMatch,

Directives from mod_alias can't check the query string. You'll need mod_rewrite:
RewriteEngine on
RewriteCond %{QUERY_STRING} mode_app
RewriteRule ^  http://server2%{REQUEST_URI} [R=301,L]

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
Make the most of your online learning experience.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

718 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