se11
November 4, 2019, 4:08pm
1
Hello,
I wanted to redirect http://novemgold.com
to https://www.novemgold.com
.
The https redirect works but I can not figure it out, how to redirect to www
Followed this tutorials:
Hi,
Attempting to minimize redirects on our sites. For example, a browser user enters:
“rosemariespeaks ‘dot’ com”
{{SORRY, HAVE TO USE ‘dot’ instead of . - system thinks I’m a spammer.}}
I want to redirect to www ‘dot’ rosemariespeaks ‘dot’ com AND force the use of SSL.
In the example below (nginx), I’m able to do this successfully. However, its a couple of redirects.
Wondering if this logic can be performed at the dns level (ie CF), and how would I go about implementing it. Thanks for…
without any success.
working nginx config for https redirect:
`server {
# ports
listen 80;
listen [::]:80;
# domain name
server_name novemgold.com www.novemgold.com;
# Redirect all non-https requests
rewrite ^ https://novemgold.com$request_uri? permanent;
#return 301 https://novemgold.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/novemgold_com.pem;
ssl_certificate_key /etc/ssl/novemgold_com.key;
server_name novemgold.com www.novemgold.com;
# if ($host = 'novemgold.com') {
# return 301 https://www.novemgold.com$request_uri;
# }
root /var/www/novemgold.com;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404 /index.php?$args;
}
.....
`
The commented out section of the config are mostly what I tried out
se11
November 4, 2019, 4:12pm
2
Also, activating this page rules results in the browser error “too many redirects”
Remove this rule and switch on the Always Use HTTPS feature in the SSL/TLS > Edge Certificates tab.
If you don’t want the redirect to apply to the whole zone, you can instead keep the Page Rule, but change the origin URL to start with http://
, to avoid the redirect loop.
se11
November 4, 2019, 4:34pm
5
Hi,
page rule was not active.
Remove this rule and switch on the Always Use HTTPS feature in the SSL/TLS > Edge Certificates tab.
done that:
commented out this part:
# rewrite ^ https://novemgold.com$request_uri? permanent;
and activated this rule:
if ($host = 'novemgold.com') { return 301 https://www.novemgold.com$request_uri; }
getting again: browser error “too many redirects ”
Sorry, I think I misread your OP. You should just set the Always Use HTTPS and your original page rule, that should take care of both redirects. The page rule will trigger first, and will redirect any example.com
request to https://www.example.com
. Requests with www.
but not https://
will be handled by the Always Use HTTPS. So the combination should work, unless there are other redirects at your origin that contradict these.
I know nothing about Nginx, can’t help with that. I would think it possible to create a http or naked single redirect, as I do with .htaccess, you’d need to search this on StackOverflow or similar sites.
se11
November 5, 2019, 8:25am
7
Removing the redirects:
server {
# ports
listen 80;
listen [::]:80;
# domain name
server_name novemgold.com www.novemgold.com;
# Redirect all non-https requests
#rewrite ^ https://novemgold.com$request_uri? permanent;
#return 301 https://novemgold.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/novemgold_com.pem;
ssl_certificate_key /etc/ssl/novemgold_com.key;
server_name novemgold.com www.novemgold.com;
# if ($host = 'novemgold.com') {
# return 301 https://www.novemgold.com$request_uri;
# }
root /var/www/novemgold.com;
index index.html index.htm index.php;
and activating the page rule in cloudflare triggers the “too many redirects error”
se11
November 5, 2019, 10:59am
8
Curl to http and https without (cloudflare page rule):
http://novemgold.com
--------------------
HTTP/1.1 301 Moved Permanently
-> Location: https://novemgold.com/
HTTP/2 200
---------+++++-----------
https://novemgold.com
--------------------
HTTP/2 200
system
Closed
December 5, 2019, 10:59am
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.