Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7582787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:31:17+00:00 2026-05-30T18:31:17+00:00

I am running some PHP code to my browser. If I navigate to a

  • 0

I am running some PHP code to my browser.

If I navigate to a URL like google.com it tells me the document has moved here . . i.e to another google link.

I set cURL follow location to true.

Also. When the query actually goes through it forces my browser to download a webpage in a .gz file.

Please help. I don’t want it to download. I want it to display.

curl_setopt($ch, CURLOPT_URL, trim("http://".trim($host).$q)); 
curl_setopt($ch, CURLOPT_PORT, intval(trim($port)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $v);

EDIT ::

Your browser sent a bad request when requesting sites like stackoverflow.com. . even 4shared.com does the same thing.

Here is the HTTPHEADER array I use in cURL;

Array
(
    [0] => Proxy-Connection: Close

    [1] => Cache-Control: max-age=0

    [2] => User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1017.2 Safari/535.19

    [3] => Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

    [4] => Accept-Encoding: gzip,deflate,sdch

    [5] => Accept-Language: en-US,en;q=0.8

    [6] => Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

    [7] => Cookie: __qca=P0-9

    [8] => Connection: Close
)

It’s the same curl code I use above.

    Host: stackoverflow.com                                 
    Q: /questions/tagged/java
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:31:19+00:00Added an answer on May 30, 2026 at 6:31 pm

    For solving the gzip problem: try setting CURLOPT_ENCODING to an empty string before setting CURLOPT_HTTPHEADER. The problem is that cURL is not expecting a compressed response (since you haven’t set what encodings it should accept) but manually ask for a compressed response anyway using your custom HTTP headers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some simple code like this: <?php setcookie(user,test, time() + 3600); echo $_REQUEST['user'].<br>;
While reviewing some PHP code I've discovered a strange thing. Here is the simple
I'm working on some PHP code with a partner, and were both running a
I want to test some PHP on my local machine running Windows XP Professional.
does FastCGI work well with PHP? It seems that some people running Ruby on
I have been having some problems trying to get my PHP running. When I
I am doing some maintenance work on an older system that is running PHP
I'm running some JUnit tests on my applications. Every test has a for loop
I was running some dynamic programming code (trying to brute-force disprove the Collatz conjecture
I'm have some php code: <? $cmd=mkfifo /tmp/myfifo;; system($cmd); $cmd=echo 1 > /tmp/myfifo 2>&1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.