Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
 All Forums
 Technical
 PHP (Unix / Linux / Apache) versions
 Sub-Domain .htaccess rewrite
Author « Topic »  

Mikelli
Ecommerce Template Guru

USA
1613 Posts

Pre-sales questions only
(More Details...)

Posted - 07/30/2021 :  09:28:34  
The problem is if entered as www.subdomain.site.com it displays as insecure / can't display / trouble finding site. if entered with https://subdomain.site.com/ site loads fine. If enter as https://www.subdomain.site.com it won't load. I would appreciate any help correcting this:

#HTTPS Redirection Start
RewriteEngine On
RewriteCond %{HTTP_HOST} pallet\.mysite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://pallet.mysite.com/$1 [R,L]
Header always set Content-Security-Policy: upgrade-insecure-requests
#HTTPS Redirection Stop

Michael

Vince
Administrator

42488 Posts

Posted - 08/01/2021 :  01:14:27  
Hi Michael
Maybe I'm understanding this wrong but why would you want the site to open for both subdomain.site.com and www.subdomain.site.com as wouldn't that class a duplicate content?
If you did want the site to open for www. however, would you not just ask your host to set that up for you?

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

Mikelli
Ecommerce Template Guru

USA
1613 Posts

Pre-sales questions only
(More Details...)

Posted - 08/01/2021 :  21:13:37  
Agree, but I want the rewrite rule to remove the WWW if it’s in a link or it’s typed in the address bar. If it is in the link or typed address, it’s a dead link / address. I hope that makes since, if not I’ll try rewording in the morning.

Thanks for the reply.

Michael

Mikelli
Ecommerce Template Guru

USA
1613 Posts

Pre-sales questions only
(More Details...)

Posted - 08/02/2021 :  04:16:49  
The above rule always re-directs to https, perfect!

How do I also redirect www to non-www domain? And get both redirects to work together?

I hope I'm clearer than before.

Michael

Vince
Administrator

42488 Posts

Posted - 08/02/2021 :  04:43:19  
Hi Michael
Try this...

#HTTPS Redirection Start
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} pallet\.mysite\.com [NC]
RewriteRule ^(.*)$ https://pallet.mysite.com/$1 [R,L]
Header always set Content-Security-Policy: upgrade-insecure-requests
#HTTPS Redirection Stop

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

Mikelli
Ecommerce Template Guru

USA
1613 Posts

Pre-sales questions only
(More Details...)

Posted - 08/02/2021 :  09:28:33  
In the end I did the reverse. I checked with my host and there was no DNS A file for the www.sub.domain.com. So they created it and I went to force non-www to www.sub.domain.com (opposite of earlier) so that I wouldn't get a double content penalty. Below is working. Thanks for helping.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^pallet.mysite\.com [NC]
RewriteRule ^(.*)$ https://www.pallet.mysite.com/$1 [R=301,L]

#HTTPS Redirection Start
RewriteEngine On
RewriteCond %{HTTP_HOST} pallet\.mysite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://pallet.mysite.com/$1 [R,L]
Header always set Content-Security-Policy: upgrade-insecure-requests
#HTTPS Redirection Stop

Michael
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.02 seconds. Snitz Forums 2000