Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove Subdomain from URL string , keeping the rest of URL (for replacing subdomain)
    primarykey
    data
    text
    <p>i have a location menu that has to change location, the good thing is every url exist in every city,, and every city is a subdomain</p> <pre><code>city1.domain.com.uk/index.php?page=category/238/12 city2.domain.com.uk/index.php?page=category/238/12 </code></pre> <p>Im trying this. Im trying to break the URL to remove subdomain , so i can replace it for each item in menu</p> <p>I want to get <code>index.php?page=category/238/12</code></p> <pre><code>&lt;?PHP $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https')=== FALSE ? 'http' : 'https'; $host = $_SERVER['HTTP_HOST']; $script = $_SERVER['SCRIPT_NAME']; $params = $_SERVER['QUERY_STRING']; $url = $protocol . '://' . $host . $script . '?' . $params; // break it up using the "." $urlb = explode('.',$url); // get the domain $dns = $urlb[count($urlb)-1]; // get the extension $ext = $urlb[count($urlb)+0]; //put it back together $fullDomain = $dns.'.'.$ext; echo $fullDomain; ?&gt; </code></pre> <p>But i Get this <code>php?page=category/238/12</code></p> <p>Also i havent think in a solution for an issue i will be facing with this..</p> <p>If im looking at a product the url change to something like</p> <pre><code> city2.domain.com.uk/index.php?page=item/preview/25 </code></pre> <p>But, the products dont exist in every city , so my user will get a 404.</p> <p>=(</p> <p>How can i make a conditional in the process so if <code>page=item/preview/25</code> i do replace this for</p> <pre><code>page=index/index </code></pre>
    singulars
    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.
 

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