Reputation: 356
I want to get page content using cURL but when I get it page css style is not load propertly and I don't know why.
error_reporting(E_ALL);
ini_set('display_errors', 1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL,"http://some-page.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;
Second thing is that, did I can get using cURL full working page like it is geting page by iframe? For now all links are rewrite so when I want go to subpage it's not working.
Upvotes: 2
Views: 1799
Reputation: 69967
The CSS (and probably some Javascript as well) don't load because they're using absolute or relative paths that have no meaning on your domain.
You're going to either need to find all these links in the cURL response and replace them with valid URLs on the domain (and probably rewrite regular HTML links and other assets).
Your best bet is probably to configure Apache to act as a reverse proxy so it'll do all this for you. See ProxyPass.
Upvotes: 2