Hello web developers, I have a small problem and I am not sure if it's doable using just htaccess or should I use php file_get_contents();

I have 2 sites ...

example-1.com and example-2.com

I want the content of example-1.com, whole site, to show on example-2.com.
And if someone visits example-2.com/about-us I want to show content for example-1.com/about-us

How can I do this?

Recommended Answers

All 6 Replies

Why not point both domain names to the same code so the site works with both? Would require a config change to your httpd.conf file and pointing both domain names to the same place.

Hi Dani, is it possible to do it with htaccess? I found some solutions online but it did not work for me. I am new to htaccess.

Also, no, this is not the appropriate use case for file_get_contents(). You would have incredibly poor performance doing it that way.

Hi Farrish, as Dani mentioned in a previous comment, the best solution is to create example-2.com as a parked domain of example-1.com and point to the same files.

A parked domain (also known as domain alias) shows the same content as the primary domain. The parked domain must be already registered and pointed to your nameservers.

I hope this helps.

Best regards.

This wouldn’t be a parked domain. A parked domain is the cheap method where you can pay your domain registrar a few bucks to do a 301 redirect from every URL of one domain to the other.

If you want to mirror the content, and not do visible redirects from one domain to the other with each page, you just want to point both domains to the same server IP address, and edit your Apache’s config file to listen for both domain names.

Can I do this with parked domain? If so, how?

I own both domain names. And yes, I want to mirror the first domain to the second one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.