1

I have two free domains hosted by different services

eg. GoodURL.BadFeatures.com and BadURL.GoodFeatures.com

What is a way to display the good URL in the browser but loading from the bad URL site?

At first, I was thinking of using a full page iframe but that would make it hard for normal users to share the page they are viewing (and cannot bookmark any pages they are viewing).

Then I thought maybe I can have GoodURL.BadFeatures.com request the content from BadURL.GoodFeatures.com and give only its output
(but since some users may want to log in, I need to forward all cookies - not sure how on a per user basis)

I tried placing the following in a .htaccess on the Good URL site:

RewriteEngine On
RewriteRule ^(.*) BadURL.GoodFeatures.com/$1 [P,L]

but keep getting Internal Error (500)

  • 1
    Unless you know how to secure your system from proxy attacks, do not do this! Using this feature without knowing what you are doing is extremely dangerous. Another consideration is that you will need module's enabled that will not ever be allowed on a shared server and/or with free hosting. It is very likely you will not be able to do this. It is a huge security concern. – closetnoc Jun 25 '17 at 1:49
  • 1
    What makes these URLs good and bad? – Stephen Ostermiller Jun 25 '17 at 9:03
  • Are you sure doing this will solve your issue? You may end up with performance worse than both! – Itai Jun 25 '17 at 14:21
  • spend $25 and buy cheap service with your own domain. or spend $5 and use free services with your own domain. in my opinion you have no business complaining about a bad domain name when you're not paying for a service. – iwrestledabearonce Jun 26 '17 at 14:04
1

The solution you're looking at is a proxy pass.

Your current method should be:

RewriteEngine On
RewriteRule ^(.*)$ BadURL.GoodFeatures.com/$1 [P]

Notice the '$' sign that captures the path to rewrite it. The proxy flag on mod_rewrite also skips the 'L' flag, as it's already passed the request onto mod_proxy and is ignoring all rules after processing that request.

A better method would be:

<VirtualHost *:80>
    DocumentRoot "/www/whatever"
    ServerName GoodURL.BadFeatures.com
    ProxyPass  http://BadURL.GoodFeatures.com/
    ProxyPassReverse / http://BadURL.GoodFeatures.com/
    ProxyPassReverseCookieDomain BadURL.GoodFeatures.com GoodURL.BadFeatures.com
</VirtualHost>

Using ProxyPass is preferred to rewriting due to the heavy amount of processing incurred with your current method of rewriting. This does the same thing but skips some steps and has better handling. It also solves your problem with Cookies.

I assume you're trying to combine a good hosting service with a good content manager - if it's possible to combine these onto a single server, it would greatly improve performance across the board. What you've set up here is known as a Gateway - having one server handle all requests while another focuses on content. Normally this setup has security features implemented to prevent tampering. Consider looking up options to implement this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.