Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1834

HTAccess HTTPS Redirect

$
0
0

We're having some issues with relative 301 redirects in that they go to HTTP before being corrected to HTTPS.

The site is using Cloudflare but it seems to be something at Apache level causing the issue as setting up a absolute redirect to HTTPS works just fine.

HTTP/2 301 date: Fri, 10 Jul 2026 03:00:16 GMTcontent-type: text/html; charset=iso-8859-1location: http://www.example.org/sign-up-now/server: cloudflarenel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}cache-control: max-age=0expires: Fri, 10 Jul 2026 03:00:16 GMTage: 0x-cache: MISScf-cache-status: DYNAMICreport-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=GHAo0uULLS3XkxN6TtORd%2BT2opFDDvBrIjxG%2Fv6GCsBdioS6AINK3EL7qXPwYofJyW%2Fq0eIqWncl3q%2FRXoQYSojsvKsuHvudNr3lez7CFba4Ym8hmhsLX4yUaWJubMvCWtO453azu3HV0%2FGG"}]}cf-ray: a18c5133fc7c3df3-SINHTTP/1.1 301 Moved PermanentlyDate: Fri, 10 Jul 2026 03:00:17 GMTContent-Type: text/htmlConnection: keep-aliveServer: cloudflareNel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}Location: https://www.example.org/sign-up-now/Cf-Cache-Status: DYNAMICReport-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=eUiogm3%2Bv5AUVRvUMKOqycE4fyjJOqi5lanwS%2BoYIo9CGis8NgAmMWJj5DMy25DKpHVEXnQHYP41ICPcAHV8fqi%2FtwbnOprt07MiS3F32RfyjzUf0tY1g8UDXu0s8s%2BdKHjf1hlSHEkg%2Btuh"}]}CF-RAY: a18c51360c239c92-SINHTTP/2 301 date: Fri, 10 Jul 2026 03:00:17 GMTcontent-type: text/html; charset=UTF-8server: cloudflarenel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}location: /sign-up-now/cache-control: max-age=0expires: Fri, 10 Jul 2026 03:00:17 GMTvary: Accept-Encoding,User-Agentage: 0x-cache: MISScf-cache-status: DYNAMICreport-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=1FEO%2BUG3KPKdw0kfRdOyaduJ1jzYA%2FZptF3cpn4p97Dhi4%2BU2nfxHmGpteVWDqzZ4hcDt80deCvtIY9lKCvz4Q7cXRNALCc0k5yqulLMzgPkOkzWyYyN1cyRSGr%2Bfwa0b9cW9LY8PSHXzfsL"}]}cf-ray: a18c51379f533df3-SINHTTP/2 200 date: Fri, 10 Jul 2026 03:00:20 GMTcontent-type: text/html; charset=UTF-8server: cloudflarevary: Accept-Encodingvary: Accept-Encoding,User-Agentlink: <https://www.example.org/?p=4783>; rel=shortlinkexpires: Thu, 19 Nov 1981 08:52:00 GMTcache-control: no-store, no-cache, must-revalidatepragma: no-cachex-breeze-cache-write: SUCCESScache-provider: CLOUDWAYS-CACHE-DCset-cookie: PHPSESSID=fanjpmidv3ogok05vv8mn5l53o; path=/last-modified: Fri, 10 Jul 2026 03:00:20 GMTage: 0x-cache: MISSnel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}cf-cache-status: DYNAMICreport-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=ALPPwIPKP6P970RRc8wVmS2%2B9WZotzJGoYOW8BeOAz9zEI%2FQNhnDwYLN74f2uweMqoZext7AWCpCqvHP27RsUddU%2B241VqPQGqXeJ%2F%2F3svjPhPgc%2BOnHW9IhxLMbW%2F8GXdImzJNOc0xb3PQI"}]}cf-ray: a18c5139e8fe3df3-SIN

After much discussion, the hosting provider has basically said all 301's need absolute URLs, although this can obviously be done with variables to minimize the rule set (https://%{HTTP_HOST}), is this advice correct or are we being brushed off?

We're forcing HTTPS on HTAccess;

RewriteEngine OnRewriteCond %{HTTP:X-Forwarded-Proto} !httpsRewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

And here is an example 301;

<IfModule mod_rewrite.c>    RewriteEngine On    RewriteRule ^sign\-up/?$ sign\-up\-now/? [L,R=301]</IfModule>

Any advice would be great as we've used relative URLs for many sites and if this is now an issue it's going to be a pain to resolve.


Viewing all articles
Browse latest Browse all 1834

Latest Images

Trending Articles



Latest Images