htaccess redirect to no www include ssl

htaccess redirect to no www include ssl

So there are sometimes when we need to htaccess redirect our site to an ssl and remove the www part of it. Here is a code to help webmasters do that. What you need to do is look for the file called .htaccess. It will be in the root folder of your site. It is invisible to everyone that does not have access to the root file of your site.  For rewrite rules such as this one you have to make sure that you start the code out with RewriteEngine On. This tells the server that we will be rewriting urls for our guests. You can use the htaccess rewrite rule on any apache server running Linux. There are several different types of rewrite rules that you can apply to a website using the htaccess rewrite rules. This is also a good way to make your site SEO friendly to the search engines and will help you get away from SSL errors when a web surfer puts the www in front of the url when it is not used.

[code]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]

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L][/code]

If you just want to get rid of the www use the code below in your htaccess file.

[code]RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L][/code]

If you want to add the www use the code below

[code]RewriteEngine On RewriteCond %{HTTP_HOST} ^$ RewriteRule (.*)$1 [R=301][/code]

This code can only be used on an Apache server.

Enter your email address:Delivered by FeedBurner
htaccess redirect to no www include ssl was last modified: May 11th, 2015 by Maximus Mccullough

htaccess redirect

Leave a Reply

Your email address will not be published. Required fields are marked *