Welcome to WebmasterWorld Guest from 54.205.60.49

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess for canonical, SSL and hostname

   
9:53 am on Nov 20, 2013 (gmt 0)

5+ Year Member



This is what we have now:
# redirect no-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]

# parse php in html PHP 5.4
AddHandler x-mapp-php6 .html .htm

We need:
1. no-www to www redirect
2. SSL certificate redirect
1&1 support advice: If you ordered the ssl with www then you will need to add this to your current .htaccess file or to a new .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com [L,R=301]

3. hostname to domain name redirect
Since adding .htaccess at the top, we have duplicate content on google for same pages with hostname (1&1) and domain name.
For example:
www.example.com/info/about-us.htm
www. s1796*****.onlinehome.us/info/about-us.htm

Please advice. Thank you.

[edited by: phranque at 9:32 am (utc) on Jan 20, 2014]
[edit reason] exemplified domain [/edit]

9:38 am on Jan 20, 2014 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]

We need:
1. no-www to www redirect

you would be better off with something like this:
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


2. SSL certificate redirect

what have you tried?

3. hostname to domain name redirect

the change i described above should also handle the hosting company hostname redirect.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month