Rewriterule for directing part of a servers traffic

Posted on 2007-07-26
Last Modified: 2010-03-04
I need to redirect a part of a website to a new webserver
where ( becomes and this string (Store_Code=abcd) is in the uri.

if Store_Code=abcd

Nothing I've tried works
Question by:kiqkinas
    LVL 51

    Accepted Solution

    RewriteCond %{SERVER_NAME} ^$
    RewriteCond %{REQUEST_URI} .*\?Store_Code=abcd
    RewriteRule .*

    # Note: that's the lazy aproach according the lazy description ;-)
    LVL 1

    Author Comment

    Well not quite.

    I had originally tried:
    RewriteCond %{REQUEST_URI} !-s
    RewriteRule ^([^/]+)[^/]+)Store_Code=Bdix([^/]+).*$ $$2Store_Code=Bdix$3 [PT,NE]

    My difficulty is that what comes before and after Store_Code=Bdix can change.
    you sugestion of RewriteCond %{REQUEST_URI} .*\?Store_Code=abcd may point me in a better direction.

    LVL 1

    Author Comment

    Still cant get this to work

    RewriteEngine on

    RewriteCond %{SERVER_NAME} ^$
    RewriteCond %{REQUEST_URI} .*=Bdix
    RewriteRule ^(.*)$$1 [R=permanent,L]

    The problem seems to be in RewriteCond %{REQUEST_URI} .*=Bdix.
    If I eliminate the line the entire site gets re-directed as expected changing just the domainname in the uri.
    I've tried dozens of variation on the condition to no avail. Please help.
    .*=Bdix. *

    LVL 1

    Author Comment

    Found it:
    RewriteEngine on

    RewriteCond %{SERVER_NAME} ^$
    RewriteCond %{QUERY_STRING} .*=bdix.* [NC]
    RewriteRule ^(.*)$$1 [R=permanent,L]
    LVL 51

    Expert Comment

    .*bdix.* is required if you have more parameters in the URI

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
    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). #…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    761 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

    14 Experts available now in Live!

    Get 1:1 Help Now