Redirect http to https and www

To forward a website to use both www. and https:// use the following in an .htaccess file:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


If that code doesn't work please try the following...


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

  • 4 Користувачі, які знайшли це корисним

Ця відповідь Вам допомогла?

Схожі статті

Redirect Internet Explorer visitors to a supported browsers page

Redirect users of Internet Explorer to a supported browsers page or any other page.  To do this,...

How can I change the default page / document?

Create a .htaccess file, include the below information into it and upload it to the public_html...

Adding HTML to Site Builder

When adding HTML code/source in site builders be sure you are in HTML mode. There is often a...

How do I parse html files as shtml?

Create an .htaccess file in the directory needed and add the following: AddHandler...

How can I make search engine friendly urls with my app?

The best source is the support forums for the particular app. You can also check the following...