...

View Full Version : removing all www.



jl9148
11-15-2006, 05:33 AM
my member script kinda messes up whenever there is www in front of my url.

so is there anyway to edit the htaccess so ALL urls beginning with a WWW will automatically change to one without the WWW?

ess
11-15-2006, 11:32 AM
I haven't tested this code...as I have never needed to use it...but try it out and let's know if there are any errors.

RewriteCond %{HTTP_HOST} !^your_site_domain_here\.com$ [NC]
RewriteRule .* http://your_site_domain_here.com/ [L,R=301]

Note: you need to set ReWriteEngine on

good luck

UberDragon
11-16-2006, 01:25 PM
my member script kinda messes up whenever there is www in front of my url.

so is there anyway to edit the htaccess so ALL urls beginning with a WWW will automatically change to one without the WWW?


I'm not sure how you would edit the .htaccess but this could be accomplished with PHP also.


<?php
if (substr($_SERVER['SERVER_NAME'],0,3) == 'www') { // if www. is subdomain
$url = substr($_SERVER['SERVER_NAME'],4,strlen($_SERVER['SERVER_NAME'])); // remove the www.
$url .= $_SERVER['PHP_SELF']; // Add directory and file name to url
header('Location: http://'.$url); // redirect the browser to url without www
}
?>

Placing that on the very top of the web page will force no www subdomain. Hope this helps.

~UberDragon



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum