My site is mentioned in settings as www. But when run without www it doesn’'t execute. I want to make it executable in both ways, i.e. with www and without www. Kindly help as my site is not executable.
Moreover, does it effect SEO?
Add the following to apache configuration (Context: server config, virtual host, directory, .htaccess).
RewriteEngine on
RewriteCond %{HTTP_HOST} ^YOUR_HOST.COM
RewriteRule ^(.*)$ http://www.YOUR_HOST.COM/$1 [R=301,L]
Check apache mod rewrite docs for more info.
my site is on wordpress and there’s no htaccess in wordpress folder. Kindly provide some help. its urgent.
thanks.
You must add
ServerAlias YOUR_HOST.COM
and
RewriteEngine on
RewriteCond %{HTTP_HOST} ^YOUR_HOST.COM
RewriteRule ^(.*)$ http://www.YOUR_HOST.COM/$1 [R=301,L]
to your VirtualHost section of the apache conf.
But there’s one in either the server root or public root, I assume? If not, you probably ought to create one at the top-most level for useful things such as this. And a lot more besides.
Gvre: shall i add these both codes to .htaccess? Shall I make any change to these code (based on my domain name) or just as same as it is?
thanks, i found htaccess
The context for ServerAlias is virtual host (in apache conf). Check ServerAlias Directive for more info.
To answer your question in regards to SEO, yes it does affect it. Google will see www.yourdomain.com and yourdomain.com as two seperate domains. With the code they are providing you above it will redirect all requests to the same.
My site is working well without www but not executable when run with www. I want it to run with www too. Kindly help with this.
Can anyone please tell me htaccess code in the easiest way?
Thank you all! I’ve dont it.
I do not like the www version, because it - in my opinion, with the rule simpler is better - makes only noise in the domain.
So I suggest to use the following .htaccess rule:
RewriteCond %{HTTP_HOST} !^example\\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
It will redirect the www(and other alias domains) version to the not-www version.
When I read your reply I wasn’t too keen on the idea of a non-www url, however after thinking about it and looking around the net, there appears to be a decent amount of sites using the non-www method.
You are 100% correct with regards to www making noise.
Yes you are correct - in point of search engine’s - they consider two different domain…so make sure you redirect it with 301- permanent redirect.
It should be www.example.com and if we typt example.com it should redirect it to www.example.com. Instead of opening example.com…
And if both are opened then google treat it to different URL… In this case your own site will become competitor of itself.
To resolve this problem do canonical URL…
I had this problem with a site of mine and was happy to discover that an “alias” entry would fix all my woes. There is nothing like that sinking feeling as a newbie when you think of the traffic you are potentially missing.
it can be done from the cpanel of your website