skip to Main Content

I am creating an SEO analyzer. One part of it is to find whether a website has gzip enabled or not.

I found that gzip can be done either by .htaccess or in apache or Nginx. So how can i find whether entered website has gzip enabled or not?

Also when i open a website like this : www.example.com/.htaccess it is giving me a error saying “permission denied“.

4

Answers


  1. Chosen as BEST ANSWER

    ok thank you guys. I have written the code to check gzip of a website. Here it is...

    <?php
    $headers = get_headers("http://www.example.com", 1);
    echo $headers['Content-Encoding'];
    ?>
    

  2. htaccess is a hidden system file so you cannot access it, usually you would use phpinfo(); to look at your php settings.

    Login or Signup to reply.
  3. Try analyzing headers with getallheaders. Look for something like: Content-Encoding
    More info here: https://en.wikipedia.org/wiki/HTTP_compression

    And here is example code:

    foreach (getallheaders() as $name => $value) {
        if ($name == 'Content-Encoding') {
            echo 'Encoding is: ' . $value;
            break;
        }
    }
    
    Login or Signup to reply.
  4. First of all:
    .htaccess should be only be accessible through the file system, for example through ftp.

    As for the gzip detection, check the response header for: Content-Encoding gzip

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search