You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Desilets, Alain" <Al...@nrc-cnrc.gc.ca> on 2012/05/16 14:06:24 UTC

[users@httpd] Redirecting a domain to another using Rewrite rules

I need to forward a domain www.wiki-translation.com to a different location wiki-translation.wiki4us.com, while preserving the original url. 

I have been trying to do this for 30 mins now, using Rewrite rules, and nothing works.

For example, thje Parked domains CPanel functionality created the following lines in my .htaccess file:

---
RewriteCond %{HTTP_HOST} ^wiki\-translation\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.wiki\-translation\.com$
RewriteRule ^/?$ "http\:\/\/wiki\-translation\.wiki4us\.com\/" [R=301,L]
---

This works somewhat, in the sense that it redirects www.wiki-translation.com to wiki-translation.wiki4us.com. But it does not preserve the original URL.

I also tried this replacing the R flag with a P (proxy) flag:

---
RewriteCond %{HTTP_HOST} ^wiki\-translation\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.wiki\-translation\.com$
RewriteRule ^/?$ "http\:\/\/wiki\-translation\.wiki4us\.com\/" [R=301,L]
---

But it yields the error:

---
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /.
Reason: DNS lookup failure for: wiki-translation.wiki4us.com
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
---

Then I tried this 

---
RewriteCond %{HTTP_HOST} ^wiki\-translation\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.wiki\-translation\.com$
RewriteRule ^/?$ "http\:\/\/www\.wiki4us\.com\/wiki\-translation\/" [P,L]
---

where www.wiki4us.com/wiki-translation/ is the actual location that the subdomain wiki-translation.wiki4us.com points to.

This one worked kindof. It does point to the right location, and preserves the original url www.wiki-translation.com. But the page comes out looking wrong, presumably because all the CSS files are not accesible as www.wiki4us.com/wiki-translation/*.css (just as wiki-translation.wiki4us.com/*.css). Dunno why.

Any advice you may have will be greatly appreciated.

Thx.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirecting a domain to another using Rewrite rules

Posted by Pete Houston <ph...@openstrike.co.uk>.
On Wed, May 16, 2012 at 07:39:17PM -0400, Desilets, Alain wrote:
> When I try to go to www.wiki-translation.com, I see the url wiki-translation.wiki4us.com in the browser (which is not what I want... I want to keep the original www.wiki-translation.com url). 

In that case the approach will depend on whether both requests are
handled by the same server. If they are, then a ServerAlias is what you
need. If not, a proxy will be required.

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

RE: [users@httpd] Redirecting a domain to another using Rewrite rules

Posted by "Desilets, Alain" <Al...@nrc-cnrc.gc.ca>.
Thx for the tip, but it doesn't seem to work. For example, I just tried this:

---
Redirect / http://wiki-translation.wiki4us.com/
---

When I try to go to www.wiki-translation.com, I see the url wiki-translation.wiki4us.com in the browser (which is not what I want... I want to keep the original www.wiki-translation.com url). In addition, I get:

---
The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
---


Alain
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirecting a domain to another using Rewrite rules

Posted by Pete Houston <ph...@openstrike.co.uk>.
On Wed, May 16, 2012 at 05:06:24AM -0700, Desilets, Alain wrote:
> I need to forward a domain www.wiki-translation.com to a different location wiki-translation.wiki4us.com, while preserving the original url. 
> 
> I have been trying to do this for 30 mins now, using Rewrite rules, and nothing works.

Why would you use a RewriteRule when you could simply use a Redirect? In
case you are not aware of this, it is documented here:

http://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107