heron
heron

Reputation: 3661

How to mask URL address?

Think I have domain.com that redirects into some.otherdomain.com. I don't want to show exact url some.otherdomain.com to my sites visitors. I need to mask my URL, so that it will look like domain.com Any possible way? .htaccess / javascript?

Upvotes: 0

Views: 15630

Answers (5)

Mike Christensen
Mike Christensen

Reputation: 91628

Assuming domain.com and some.otherdomain.com are on two physically different servers, and you can't change the DNS information for any of them, you'll need to install a reverse proxy on domain.com. You can use mod_proxy for this. The docs are at:

http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

The following information is what you need to pay attention to:

A reverse proxy, by contrast, appears to the client just like an ordinary web server. No special configuration on the client is necessary. The client makes ordinary requests for content in the name-space of the reverse proxy. The reverse proxy then decides where to send those requests, and returns the content as if it was itself the origin.

There's an example of a reserve proxy in the docs, but you'll want something like this:

ProxyRequests Off

<Proxy *>
  Order deny,allow
  Allow from all
</Proxy>

ProxyPass / http://some.otherdomain.com/
ProxyPassReverse / http://some.otherdomain.com/

Basically, any request that domains in will be proxied over to some.otherdomain.com - The local web server will forward the request over, buffer the data from otherdomain.com, then write the same data back out as if it were local data. Hope this helps!

Upvotes: 3

anubhava
anubhava

Reputation: 785276

On the Apache webserver of domain.com you have to enable:

  1. mod_proxy
  2. mod_rewrite
  3. .htaccess

Once these requirements are completed then put this code in your .htaccess under DOCUMENT_ROOT of domain.com:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^ http://some.otherdomain.com%{REQUEST_URI} [L,P]

Important flag here is P (Proxy) which will basically make domain.com proxy all the requests to some.otherdomain.com without showing it in the browser. See here for more documentation on this flag: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule

Upvotes: 1

Mendhak
Mendhak

Reputation: 8785

The easier way would be to set up a page on domain.com with an iframe on it and set the source of the iframe to some.otherdomain.com. However, a user will be able to view source of the page and see that your iframe is pointing to some.otherdomain.com.

<iframe src="http://some.otherdomain.com/">...

The other option is to use a mod_rewrite in your .htaccess as shown in this thread.

Upvotes: 0

Tobias Krogh
Tobias Krogh

Reputation: 3932

I always think the best way is doing such things via mod_rewrite (or similar) in the server configuration (Apache or whatever is used)

Upvotes: 1

fmgp
fmgp

Reputation: 1636

The best way to hide your domain is to use a reverse proxy (apache, nginx, ...) and provide rewrite rules to it.

Upvotes: 2

Related Questions