Ssl – Redirecting https urls to the http equivalent using htaccess file

.htaccess301-redirecthttpsmod-rewritessl

The situation I have is that I have made a new website for a client, the URL format of which is http://newsite.com. The clients old website used SSL and had the URL format https://www.oldsite.co.uk. SSL is not necessary on the new site and thus has not been used.

The old site is ranking well in the search engines, and so for this reason the client would like to use 301 redirects to capture any requests made for the old pages and divert them to the equivalent pages on the new site ie. /contact.php on old site redirects to the new contact page.

The problem is that all of the search engines have indexed the https:// version of every url, and I need to redirect to a non SSL, standard http:// URL. In a nutshell what I need, is a way to catch any incoming URL with an https:// at the front, and somehow alter it to look for the http:// version of this URL instead.

The contents of my .htaccess file:

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^nielbally\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.nielbally\.co\.uk$
RewriteRule ^/?$ "http\:\/\/artcourseswales\.com\/" [R=301,L]

Best Answer

The best config is to create a virtual host for the old site name, with a redirect for all URLs.

<VirtualHost :443>
    ServerName oldsite.co.uk
    ServerAlias www.oldsite.co.uk

    RewriteRule ^(.*)$ http://newsite.co.uk$1
</VirtualHost>
Related Topic