Menu
  • HOME
  • TAGS

How to redirect non-www to www using htaccess?

.htaccess,redirect,seo,url-redirection,no-www

Why not simply: RewriteEngine On RewriteCond %{HTTP_HOST} !www\.evo\.co\.il$ [NC] RewriteRule ^(.*)$ http://www.evo.co.il/$1 [L,R=301] RewriteRule ^בניית-אתרים$ /page.php?id=1 [L] ...

Correct way of handling www. and non www. when working with sessions

php,.htaccess,session,no-www

You shouldn't use both example.com and www.example.com. You should select one and redirect the other. For example if you want to use www.example.com, then redirect example.com to www.example.com. You can do this easily in .htaccess: RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] Or in Nginx: server { listen 80; server_name...

www.domain.tld vs. domain.tld

http,web,http-redirect,no-www

OK, so apparently my research was sloppy and I posted this question on the wrong part of the vast stackexchange network. If anyone should stumble upon this question, looking for some answers, I found all the answers and links to further materials on Webmasters: Should I include “www” in my...

redirect non-www to www resulting in loop address

.htaccess,no-www

RewriteRule ^(.*)$ www.%{HTTP_HOST}/index.php/$1 [R=301,L] ^--- You forgot to prefix the hostname with http://, so Apache's rewriting as a LOCAL url Try RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/index.php/$1 [R=301,L] instead. It's basically the same rules that apply to: <img src="www.example.com/kittens.jpg" /> <img src="http://www.example.com/kittens.jpg" /> ...

How to redirect www to no-www on OpenShift properly?

.htaccess,redirect,openshift,wsgi,no-www

I had this same problem with my WordPress blog hosted on OpenShift and I fixed it with the following .htaccess rule : RewriteEngine On RewriteBase / # www to non-www RewriteCond %{HTTP_HOST} ^www.subinsb.com$ RewriteRule (.*) http://subinsb.com:80/$1 [R=301,L] ...

Redirect domain.com/folder with www to non-www and at the same time http to https

.htaccess,redirect,https,subfolder,no-www

Inside /webapp/.htaccess use this rule: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^ https://domain.com/%{REQUEST_URI} [R=301,L,NE] ...

apache redirect to naked (non-www) domain messes up pages handler

apache,.htaccess,mod-rewrite,redirect,no-www

The problem with your code is that you are applying the first two conditions only to the non-www rule. Conditions can only be tested for the rule that immediately follows them. So, you'll need to move those down, and clean up a bit: RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule...

Redirect non-www to www without specifying domain name

.htaccess,redirect,no-www

You can use that: RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] ...

HTTPS www to non-www on NGINX

ssl,nginx,https,no-www

OK, so I figured this out a while ago but forgot to post the answer, so here it is. server { listen 80; server_name www.example.com example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; server_name example.com; root /home/forge/default/public; if ($host = 'www.example.com') { rewrite ^/(.*)$ https://example.com/$1 permanent; } }...

htaccess force https & www. on domain & http no www on subdomain

apache,.htaccess,mod-rewrite,subdomain,no-www

You can use: # for main domains RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC] RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=301,L,NE] # for sub domain RewriteCond %{HTTP_HOST} ^(www\.)?sub\.domain\.com$ [NC] RewriteCond %{HTTPS} on [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^ http://sub.domain.com%{REQUEST_URI} [R=301,L,NE] You need to test this after clearing...