A little dab'll do ya
Code Snippets
WWW / No-WWW
You should really be doing one or the other. For consistency, as well as SEO's, sake.
Force the www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^your-site.com [NC]
RewriteRule ^(.*)$ http://www.your-site.com/$1 [L,R=301]Remove the www.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]
Funnily enough, I was just looking for this… Thanks!
And why this site is not working without a “www”.
http://znanje.org/
you have to put www to load the page
http://www.znanje.org/
A and Aname?
It depends on the server configuration. Most server will work without www, but I come across others once in a while.
It is working on my website. Check for the configuration above once again.
Will this also redirect https://yourdomain.com to https://www.yourdomain.com ?
Won’t this remove any subdomain? Not just the www. Just wondering.
Nope, subdomains should be fine.
I just put this on my clients site and now its not working. They are a major manufacturer and this is freaking me out!!
It is working on my website, getback with your file. Write here and would check it.
Simply a thing: it requires that Apache has enabled the rewrite module. You can ask your host for some information.
#nearly universal www – Resolve (takes away WWW from the URL on both HTTP and HTTPS)
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
When I try this in my .htaccess, the path is being removed:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,L]
This is what I get: http://www.site.com/rulezz -> site.com/
instead of what I’d like: site.com/rulezz
Any ideas?
Hi,
Removing www from the url of the website by this way may leads to stop sub-domains. I’d like to know an alternative way that make .htaccess to do that for www only not any thing before the first dot!
Some suggestions to achieve what you like, is written at the comments at this page: http://www.catswhocode.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox