Solved

.htaccess redirect question

Posted on 2004-08-04
5
891 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
  • 2
5 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 250 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 250 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

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

864 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

23 Experts available now in Live!

Get 1:1 Help Now