homepage Welcome to WebmasterWorld Guest from 54.197.94.241
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess for canonical, SSL and hostname
web2008




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

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]

 

phranque




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved