Solved

.htaccess redirect question

Posted on 2004-08-04
5
889 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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ā€¦
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secureā€¦
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

20 Experts available now in Live!

Get 1:1 Help Now