dizzy1 Posted June 22, 2011 Share Posted June 22, 2011 I have a PHP site, which I would automatically like to have www. at the front of when it loads eg. So if a user types: "example.com" it changes to "www.example.com" I would appreciate it if someone could point me in the right direction. Thanks In Advance Dizzy Link to comment https://forums.phpfreaks.com/topic/240107-php-www/ Share on other sites More sharing options...
fugix Posted June 22, 2011 Share Posted June 22, 2011 I am not an expert on .htaccess Hecer this sounds like you would need to create a rewrite rule in your htaccess file. Try googling it. Link to comment https://forums.phpfreaks.com/topic/240107-php-www/#findComment-1233416 Share on other sites More sharing options...
cags Posted July 2, 2011 Share Posted July 2, 2011 If you don't use sub-domains you could go for something like this... RewriteEngine On RewriteCond %{HTTP_HOST} !^www RewriteRule .* http://www\.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] ...or you could try... RewriteEngine On RewriteCond %{HTTP_HOST} ^mydomin.com RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L] ...or any number of other solutions depending on the exact situation. Link to comment https://forums.phpfreaks.com/topic/240107-php-www/#findComment-1237584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.