Nullified
11-01-2004, 08:58 PM
I need a php code that will forward the visitor to www.hotlinkhosting.com if the url they visit is http://hotlinkhosting.com. So if they only type hotlinkhosting.com into the address bar and hit enter or go it will forward the user to http://www.hotlinkhosting.com instead of staying at http://hotlinkhosting.com. Is this possible? I'm pretty sure it is for I have seen it on other websites such as http://download.com.
sonic10
11-01-2004, 09:54 PM
Hello,
php code won't help you. This is purely your dns settings for your domain. You should have your domain answer with or without the www prefix.
Nullified
11-01-2004, 10:04 PM
My domain does answer with and without the www, but my problem is that i don't want people viewing my page without the www there.
jasong
11-01-2004, 10:28 PM
If you move all the content into the WWW folder and not the public_html folder does that work?
SW-Ray
11-01-2004, 10:40 PM
Try using htaccess instead. Make a new file called .htaccess, and stick this in it (not tested):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
Nullified
11-01-2004, 10:50 PM
the above code gave me an internal server error.
aalkeilani
11-01-2004, 11:40 PM
do you have cpanel? there is a re-direct feature there..
Nullified
11-01-2004, 11:58 PM
Originally posted by aalkeilani
do you have cpanel? there is a re-direct feature there.. I don't want to make my homepage a nonstop loop using CPanel's redirect feature.
orbitz
11-02-2004, 12:15 AM
try this with php :)
<?php
$host = $_SERVER['HTTP_HOST'];
if ($host !="www.hotlinkhosting.com/"){
header("Location: http://www.hotlinkhosting.com");
exit();
}
?>
hope it helps :)
jasong
11-02-2004, 12:21 AM
That would work great, only then he would have to include that in ALL of his files.
I think .htaccess would be the best way.
Nullified
11-02-2004, 12:25 AM
That would also cause problems if someone was to type in hotlinkhosting.com/packages.php into the browser. he would be sent to the homepage instead.
orbitz
11-02-2004, 12:35 AM
try this then :)
<?php
$host = $_SERVER['HTTP_HOST'];
$current_url= $_SERVER['REQUEST_URI'];
$redirect_url = "http://www.hotlinkhosting.com".$current_url;
if ($host !="www.hotlinkhosting.com"){
header("Location: ".$redirect_url);
exit();
}
?>
if you have a file called header.php and use it for your site...then it would save you time ..by just editing that page :)
Nullified
11-02-2004, 12:45 AM
ty , that last one worked.
orbitz
11-02-2004, 12:49 AM
you're welcome. Glad it works for you