I've got a simple html page that just uses PHP in 2 places

<?php preg_replace('/(www\.)?([^.]*)\.(com|info)/', '${2}', $_SERVER['HTTP_HOST']); ?>
<?php echo $_SERVER['HTTP_HOST']); ?>

In page is loaded on multiple domain names, and Among the finest to show the host title as text in certain other static content

Let me remove the requirement for PHP completely, although not repalce it with another real compiler or interpreter. Let me stay away from javascript. I'm able to do without having the ability to perform a regex to obtain the second degree of the domain title, but would still like this option. Have i got any choices for carrying this out using a simpler apache module than mod_php?

Theres no problem with mod_php, I am just seeing basically can minimalize the requirements of this site I'm focusing on.

I’d mix both mod_rewrite and SSI. Set an atmosphere variable with mod_rewrite:

RewriteCond %{HTTP_HOST} ^(www\.)?([^.]*)\.(com|info)$
RewriteRule ^ - [L,E=HOST:%2]

After which access that information in SSI with:

<!--#echo var="HOST" -->

I havn't examined it buy you may have the ability to use htaccess and perform a rewrite such as this:

RewriteRule (.*) $1?httm_host=%{HTTP_HOST} [L]

I'm not sure without a doubt the % variable will come in a rewrite however it may go. You may want to make use of a condition to check on for that ? within the URL.

What about JavaScript? You simply need two small changes on the website, that may be easily done. So that you can plainly serve static HTML files. And to obtain the domain, you should use:

var domain = window.location.hostname;


Edit: To make use of mod_rewrite: You'll have to setup two identical HTML files, using the correct domain in every. You'll be able to deliver them via

RewriteCond %{HTTP_HOST} .+\.com
RewriteRule index.html index.com.html [L]

RewriteCond %{HTTP_HOST} .+\.info
RewriteRule index.html index.info.html [L]