Domain redirect keeping the URL path – URL Masking

 In Blog, HTML-HTML5, Miscellaneous

I had a site hosted at a domain and the client asked me to change the domain.

There are many ways to do such a thing.

Method1:
Apache .htaccess file associated with mod_rewrite? Most of the hosting services supports this.

RewriteEngine On
RewriteBase /
Redirect 301 / http://mynewdomain.com/

This way, all requests to the root of my old domain get redirected to the root of my new domain.
But what if I try yo access some path inside my old domain? It would raise a 404 error because it does not have the content anymore.
I want that if the user access http://myolddomain.com/path/ it redirects him to http://mynewdomain.com/path/. So I ended up with this:

RewriteEngine On
RewriteBase /
RedirectMatch 301 (.*)$ http://mynewdomain.com$1

 

Method2:

Using The FRAMESET Tag For URL Masking.

This method hides all visual cues that the web page being displayed is not at the URL in the browser’s address bar (unless the web page being displayed itself contains images or wordage that provide clues).

What you do is create a FRAMESET web page that loads the target web page.

Make a web page with the following code. Change the URL in the third line of the code to the URL of the web page to be displayed in the browser.

<frameset rows="100%">
  <frameset cols="100%">
    <frame src="http://domain.com/page.html" frameborder="0" scrolling="no">
  </frameset>
</frameset>

Put only the above into the FRAMESET web page. Use no HTML or BODY or other normal web page tags.
Upload the FRAMESET web page to your server. Load the FRAMESET web page into your browser.
You’ll notice that the URL of the FRAMESET web page is in your browser’s address bar even while a different web page, the one you specified in the third line of the above code, is displayed in the browser window.
That’s the simplicity of URL masking with a FRAMESET tag.

 

Method3:

Using IFRAME Tag For URL Masking.

This method can leave visual cues that the page being displayed is not the page at the URL in the browser’s address bar.

The clues can be (other than clues the web page being displayed itself may contain), depending on the dimensions of the IFRAME compared to the dimensions of the displayed web page:

  1. Scrollbars appear on the IFRAME. When the displayed web page is larger than the dimensions of the IFRAME tag, and the IFRAME is allowed to display scroll bars, scroll bars will appear for the site user.

  2. Part of the displayed web page is cut off. When the displayed web page is larger than the dimensions of the IFRAME tag, and the IFRAME is prevented from displaying scroll bars, the excess of the displayed web page is cropped.

  3. The browser window scroll bars allow the user to scroll down past the end of the displayed page. When the dimensions of the IFRAME tag exceed that of the displayed web page, and the dimensions are larger than the browser window itself, scrollbars for the browser window will let the user scroll past the end of the displayed web page.

To use an IFRAME for URL masking, create a web page with an IFRAME that loads the target web page.

Make a web page with the following code. Change the URL in the fourth line of the code to the URL of the web page to be displayed in the browser.

<html>
<body>
<iframe 
  src="http://domain.com/page.html" 
  frameborder="0" 
  width="960" 
  height="2500" 
  scrolling="no">
</frameset>
</body>
</html>
</iframe>

Upload the IFRAME web page to your server. Load the IFRAME web page into your browser.
You’ll notice that the URL of the IFRAME web page is in your browser’s address bar even while a different web page, the one you specified in the fourth line of the above code, is displayed in the IFRAME tag.

Recent Posts
Showing 6 comments
  • rabindra

    Nice post. Both methods are working to URL redirecting. Keep posting like this.

  • Nikhil Jhunjhunwala

    Thank you for the Information

  • Noor

    This was really helpful

  • Nikhil Jhunjhunwala

    The information was very accurate

  • muffa

    That is very attention-grabbing, You’re an overly professional blogger.
    I have joined your feed and look forward to in search of
    more of your magnificent post. Also, I have shared your web site in my social networks

  • Digital Roy

    Very good information on using iframe tag for url masking

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search