Technology

Borrowing a Whole Site from Another Domain

This post delves into the principles behind domain mirroring, particularly focusing on utilizing Apache's Rewrite module and PHP's CURL for website cloning. A cautionary note is also given regarding the potential misuse for phishing.

Sangrak

First and foremost, this method can be quite risky. Although it was not the initial intention, upon completion, it became apparent that this could easily lend itself to acts reminiscent of phishing sites.

Hence, detailed methods will not be disclosed, only the principles. Those with the capability will grasp the concept even without specific examples, while those without are advised to study further before delving into such dubious areas.

Prerequisites

Your server needs to have Apache with the Rewrite module enabled, and PHP with the CURL module. Additionally, Apache's settings must allow for .htaccess usage. The rest is up to you to figure out.

Operational Structure

The structure is fairly straightforward.

All page addresses accessed under your domain are redirected to a single .php file by the Rewrite engine. This php file then needs to fetch the requested subdirectory/filename from the target domain. In other words, use RewriteRule ^(.*) to redirect everything into rewrite.php?$1, and from there, your rewrite.php file will read the $1 subaddress from the target domain.

For example, if the target site is http://www.naver.com, and your domain is http://test.awhile.us, accessing http://test.awhile.us/css/navermain.css?20110502 should ensure that http://www.naver.com/css/navermain.css?20110502 is fetched. This effectively turns the real address into:

http://test.awhile.us/rewrite.php?/css/navermain.css?20110502

The php file then utilizes CURL to retrieve http://www.naver.com/css/navermain.css?20110502.

Additional Tuning

The reason for using CURL is to ensure the operation works smoothly and accurately.

  1. CURL module provides nearly perfect cookie support. Specify a file with read/write permissions for cookies, and it will handle reading and writing automatically. The quality of the user experience depends on how this cookie file is structured (using IP, sessions, etc.).
  2. Header manipulation is another aspect. The server may send different headers based on the extension or page. Thus, it's necessary to dynamically adjust, manipulating headers received from the CURL request and using the Header function to change them accordingly.
  3. Changing the domain names within the content fetched from another domain to your own domain is a simple yet crucial step. This operation is key to resolving many important issues.
  4. Flavor tuning involves adding any personal touches, like JavaScript or CSS, to the fetched HTML source. Ensure these are placed correctly, such as script and style tags just before the tag.
  5. Additional tuning for using files from your own server instead of fetching everything externally. This can be done by tweaking the .htaccess file or the php file itself, depending on the level of precision desired.

More on this topic