Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

.htaccess redirect question

Posted on 2004-08-04
5
Medium Priority
?
898 Views
Last Modified: 2010-03-04
Hi,

I was wondering whether it was possible for the htaccess file to redirect the following requests, if my domain is www.mydomain.com:

http://www.mydomain.com/search/search?key=foo&id=1234

to

http://www.externaldomain.com/search/search?key=foo&id=1234

Basically what I want to do is to is just redirect any requests that come to my domains search folder to an external domain. Is this possible using htaccess and what is the code to do it?

Thanks
0
Comment
Question by:jambo69
[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
5 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 1000 total points
ID: 11713891
RewriteCond %{HTTP_HOST} !^www.externaldomain.com$
RewriteRule ^(.*)$ http://www.externaldomain.com/$1
# just one possibility matching your ambigous requirement ;-)
0
 
LVL 9

Assisted Solution

by:rjkimble
rjkimble earned 1000 total points
ID: 11714383
I think that the rewrite rule should be this (note the "/" and the flags):

RewriteRule    ^/(.*)$    http://www.externaldomain.com/$1    [R,L]

If you want to restrict it to just /search/search, you can do this:

RewriteRule    ^/search/search$    http://www.externaldomain.com/search/search    [R,L]

You probably don't need the RewriteCond line, and you need to make sure that the rewrite engine is on. My suggestions look like one of these:

RewriteEngine on
RewriteRule    ^/(.*)$    http://www.externaldomain.com/$1    [R,L]

or:

RewriteEngine on
RewriteRule    ^/search/search$    http://www.externaldomain.com/search/search    [R,L]

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11714550
hehe, that was already coverd in "just one possibility"
anyway, useful suggestion too ..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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). #…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

610 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