Answer the question
In order to leave comments, you need to log in
How to load the content of another site in your own?
I decided to make a multi-regional site. In order not to make separate sites and fill them one by one, I decided to make one main site, and subdomains will load it by passing the get parameter - city. After that, depending on the city, different SEO text will be displayed on the main site. Everything else is identical. The site loads normally, but when you click on the links, it leaves the subdomain. How to avoid it?
Here is the code, all examples are working:
<?php
$domen = "http://sd-multi.ru";
$city = "vlad";
// 3 способ
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $domen);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
// 1 способ
echo file_get_contents($domen);
// 2 способ
$array = file($domen);
foreach ($array as $line) {
echo $line;
}
// 4 способ
$fp = fopen($domen, "r");
while(!feof($fp)) {
echo fread($fp, 1);
}
fclose($fp);
Answer the question
In order to leave comments, you need to log in
I decided to make a multi-regional site.
First, why is all this in PHP? There is also Nginx. It is faster and more productive))
Make all links on the main site relative, if it is not possible, do it in Nginx during proxying
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question