Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert NGINX rewrite rule to PHP
    primarykey
    data
    text
    <p>I've this NGINX rewrite URL:</p> <pre><code>if ($http_host !~ "([a-zA-Z0-9.-]+)\.example\.com(.+)") { rewrite ^ http://example.com/browse.php?u=http://$1$2? permanent; } </code></pre> <p>I want to convert the rule to PHP because my host does not let me change the server_name in NGINX to this: *.example.com</p> <p>I've tried something like this: (This script is located in index.php at my domain and I've turned <em>DNS-wildcard</em> on)</p> <pre><code>&lt;?php function unparse_url($parsed_url) { $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; } if(preg_match('/^([a-zA-Z0-9.-]+)\.example\.com\/(.+)$/', $_SERVER["SERVER_NAME"])){ unparse_url(parse_url($_SERVER["SERVER_NAME"])); header('Location: $schemeexample.com/browse.php?u=$scheme$host$port$path$query$fragment'); } else { ?&gt; &lt;html&gt; **HTML CONTENT HERE** </code></pre> <p>As you can see, it's parsing the url with parse_url and convert it back to string from the parsed url.</p> <p>Unfortunately this script is not working I'll get the content of the HTML page. Somebody has an answer?</p> <p>Thanks in advance.</p> <p>(<a href="http://www.php.net/manual/en/function.parse-url.php#106731" rel="nofollow">Function unparse_url comes from here</a>)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload