0

We have created a bunch of landing pages on a Joomla CMS system, such that the URL for each landing page is www.domain.com/page1.html and www.domain.com/page2.html, and so on. Of course the page1.html isn't really an HTML file it is a dynamic CMS page, just rewritten with htaccess.

The goal is to have one of our other domains, something like www.uniquedomain1.com show the content of www.domain.com/page1.html. Or, another domain like www.uniquedomain2.html show the content of www.domain.com/page2.html.

This needs to be search engine friendly so we can't use URL masking. Also we can't use HTACCESS redirects as this actually changes the URL in the browser bar. Need to keep the www.uniquedomain1.com URL in the browser bar.

Tried Apache VirtualHost options without any luck. You can park in a directory but not from a URL.

Ended up parking the domains on one folder, and then creating a PHP script to detect the domain host and then use CURL to query the correct url and deliver content. This whole thing seems ridiculously over complicated, and of course CURL isn't the best option, but it is all we could get to work.

Any thoughts on how to do this, or a better solution?

Zach S
  • 23
  • 5

2 Answers2

0

You can use HTACCESS redirect rules to do it without performing a redirect.

Change the html file names to be the domain name of the desired domain like domain.tld and do something like this in an .htaccess file

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:www\.)?([a-z0-9\.-]+\.[a-z]+) [NC]
RewriteRule ^$ /%1.html [L]

A quick test of this worked for two of my test (sub)domains test.domain.tld and test2.domain.tld. Both properly redirected to files with the names test.domain.tld.html and test2.domain.tld.html without modifying the URL.

Ding
  • 3,065
  • 1
  • 16
  • 27
0

You could also just use your PHP wrapper script to grab the content of each of the miscellaneous html files and output them.

If you renamed all of your HTML files (as in my previous suggested answer) to be domain.tld.html you could do it fairly easily. Something might look like:

<?php

require($_SERVER['SERVER_NAME'] .'.html');
Ding
  • 3,065
  • 1
  • 16
  • 27
  • Correct me if I'm wrong but I believe php require has to be a physical file. These pages aren't actual HTML files, they are just dynamic pages delivered from a CMS. The .html is misleading it is just a mod_rewrite. – Zach S May 01 '13 at 01:18
  • Yeah this wouldn't work. I misunderstood that it was being generated my the cms – Ding May 01 '13 at 01:21