Hi, I just install SSL certificate to my OpenCart installation.
I want to redirect
http://www.domain.com to https://domain.com
Header check: HTTP/1.1 301 Moved Permanently
http://domain.com to https://domain.com
Header check: HTTP/1.1 301 Moved Permanently
https://www.domain.com to https://domain.com
Header check: HTTP/1.1 301 Moved Permanently
Finally:
https://domain.com
to have header check: HTTP/1.1 200 OK
I made it with this code:
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]
I'm not sure if this is the right way?
Is there any more simple or right way to do that kind of redirect?
I want to redirect
http://www.domain.com to https://domain.com
Header check: HTTP/1.1 301 Moved Permanently
http://domain.com to https://domain.com
Header check: HTTP/1.1 301 Moved Permanently
https://www.domain.com to https://domain.com
Header check: HTTP/1.1 301 Moved Permanently
Finally:
https://domain.com
to have header check: HTTP/1.1 200 OK
I made it with this code:
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]
I'm not sure if this is the right way?
Is there any more simple or right way to do that kind of redirect?
More simple way? What can be more simple, than adding a few lines to a single file? :-)
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
You can do it in 3 lines. www to non-www and http to https:
Code: Select all
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*) https://yourdomain.com%{REQUEST_URI} [R=301,L,NE]
Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
artcore wrote:You can do it in 3 lines. www to non-www and http to https:
Code: Select all
RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^(.*) https://yourdomain.com%{REQUEST_URI} [R=301,L,NE]
thank you thats works for me but this time i give error undefined in admin panel and changing any order status. how can i fix this?
Make sure you have changed ALL URLs in your config.php and admin/config.php to be your SSL URL
not working :/
admin/config.php:
config.php:uksitebuilder wrote:Make sure you have changed ALL URLs in your config.php and
admin/config.php to be your SSL URL
Code: Select all
<?php
// HTTP
define('HTTP_SERVER', 'http://kasecim34.com/');
// HTTPS
define('HTTPS_SERVER', 'https://kasecim34.com/');
admin/config.php:
Code: Select all
<?php
// HTTP
define('HTTP_SERVER', 'http://kasecim34.com/admin/');
define('HTTP_CATALOG', 'http://kasecim34.com/');
// HTTPS
define('HTTPS_SERVER', 'https://kasecim34.com/admin/');
define('HTTPS_CATALOG', 'https://kasecim34.com/');
thicode already placed.davidweb09 wrote:By Placing 301 code in your site(HTTP) htaccess file you can easily redirect your site(HTTPS) to a new address...
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*) https://domainname.com%{REQUEST_URI} [R=301,L,NE]
.htaccess redirect www to non-www with SSL/HTTPS
I've got several domains operating under a single .htaccess file, each secured via SSL. I need to force https on every domain while also ensuring www's redirect to non-www's. Here's what I'm using which doesn't work:
RewriteCond %{HTTP_HOST} ^www.%{HTTP_HOST}
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI}/$1 [R=301,L]
Example: https://www.itsmarttricks.com/
should redirect to... https://itsmarttricks.com
I've got several domains operating under a single .htaccess file, each secured via SSL. I need to force https on every domain while also ensuring www's redirect to non-www's. Here's what I'm using which doesn't work:
RewriteCond %{HTTP_HOST} ^www.%{HTTP_HOST}
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI}/$1 [R=301,L]
Example: https://www.itsmarttricks.com/
should redirect to... https://itsmarttricks.com
I'd really recommend using Google for this question. There're multiple definitions for .htaccess out there, some of the may work, some not. Stack Overflow has tons of solutions.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Why would you expect the string "<HTTP_HOST>" to ever match "www.<HTTP_HOST>"? It never will. %{HTTP_HOST} is whatever the visitor typed in for the domain name: domain.com or www.domain.com. Try this for each domain:itsmarttricks wrote: ↑Sat Jul 07, 2018 1:37 am.htaccess redirect www to non-www with SSL/HTTPS
I've got several domains operating under a single .htaccess file, each secured via SSL. I need to force https on every domain while also ensuring www's redirect to non-www's. Here's what I'm using which doesn't work:
RewriteCond %{HTTP_HOST} ^www.%{HTTP_HOST}
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI}/$1 [R=301,L]
Example: https://www.itsmarttricks.com/
should redirect to... https://itsmarttricks.com
Code: Select all
RewriteCond %{HTTP_HOST} ^domain1\.com
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^www\.domain1\.com
RewriteRule ^(.*)$ https://domain1.com/$1 [R=301,L]
You don't actually need to define a domain in .htaccess. For me this definition works:
See? No domain!RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
That may work for setups with only one domain in action, but my concern is add-on domains and subdomains, especially if they are presented in the form "protocol://maindomain/subdirectory/". You don't want to do a 301 redirect on an add-on or sub-domain and have the customer see the subdirectory form! Just be careful to test any form of the rewrite code that it doesn't expose the underlying structure. If it is now showing the subdirectory form, you'll need to add a redirect to the add-on or sub-domain form (still in one redirect so you aren't penalized), which probably means one section per add-on or sub-domain (looking at the %{REQUEST_URI} to see the subdirectory).
Who is online
Users browsing this forum: No registered users and 250 guests