PERL CGI Method
This is more commonly going to be used with older scripts and shopping cart systems if the server does not support htaccess. The following code
should work with most PERL processors. This code must precede any other output to the browser.
Code:
if ($ENV{"HTTP_HOST"} != "http://www.yourdomain.com") {
$q = new CGI;
print "Status: 301 Found\nLocation: http://www.yourdomain.com".$ENV{"REQUEST_URI"}."\n\n";
exit();
}
Unfortunately, it has been quite some time since I have done regular expressions in PERL. Any suggestions for the syntax to check if a request ends with "/index.php", "/index.cgi" or "index.html"?