Redirect page to URL without protocol?

I have problems and do not know how to solve this problem.

I have a website www.example.com. It opens in mobile browsers, and I have to redirect to something://after redirecting one action.

No matter how hard I try, I can never redirect to something://when I do this:

<?php header('Location: something://'); ?>I get: http://www.example.com/something://.

I tried with JS (location.replace.href, location.replace, etc.) also no luck.

How do I get the url to change the way I EXACTLY want it?

+4
source share
3 answers

RFC 2616 says:

= "" ":" absoluteURI

absoluteURI RFC 2396.

  absoluteURI   = scheme ":" ( hier_part | opaque_part )
  relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]

  hier_part     = ( net_path | abs_path ) [ "?" query ]
  opaque_part   = uric_no_slash *uric

  uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
                  "&" | "=" | "+" | "$" | ","

  net_path      = "//" authority [ abs_path ]
  abs_path      = "/"  path_segments

  authority     = server | reg_name

  reg_name      = 1*( unreserved | escaped | "$" | "," |
                      ";" | ":" | "@" | "&" | "=" | "+" )

  server        = [ [ userinfo "@" ] hostport ]
  userinfo      = *( unreserved | escaped |
                     ";" | ":" | "&" | "=" | "+" | "$" | "," )

  hostport      = host [ ":" port ]
  host          = hostname | IPv4address
  hostname      = *( domainlabel "." ) toplabel [ "." ]
  domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
  toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
  IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
  port          = *digit

, something://, authority - , . something://example

, , , , URL- HTTP (S) .

+2

JavaScript, :

window.location = 'customprotocol://';
window.location.assign('customprotocol://');

(.. customprotocol://) , , . , setTimeout, , customprotocol://, .

window.location = 'customprotocol://';
window.setTimeout(function() { window.location = 'http://example.com/fallback.html' }, 1);
+1

Try the JS method shown by @vitozev, or:

echo <<< EOF
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=something://">
EOF;

or

header('HTTP/1.1 301 Moved Permanently');
header('Location: something://');
header ('Content-Length: 0');
0
source

Source: https://habr.com/ru/post/1618390/


All Articles