Solved

.htaccess redirect question

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 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