Home > Mobile >  How can I get my Hostinger shared hosting server to execute .htaccess file in hidden /.well-known fo
How can I get my Hostinger shared hosting server to execute .htaccess file in hidden /.well-known fo

Time:03-14

I am on a Hostinger shared plan, trying to set a CORS header on a single TOML file that MUST reside in the public_html/.well-known folder. I have an .htaccess file in the ".well-known" folder but the Apache server will not process it.

However, if I rename the ".well-known" folder to "well-known" (just removing the period), the .htaccess file works and I can set whatever headers I want for files in that folder.

At this point I have deleted my entire site and replaced it with an extremely simple one in order to try and make this work.

The current file structure is as follows:

public_html
  /.well-known
    .htaccess
    test.toml
  /well-known
    .htaccess
    test.toml
  index.html

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Apache Header Test</title>
  </head>
  <body>
    Apache Header Test
  </body>
</html>

.htaccess (identical in the ".well-known" and "well-known" folders)

<IfModule mod_headers.c>
  Header set Access-Control-Allow-Origin "*"
</IfModule>

test.toml (identical in the ".well-known" and "well-known" folders)

Apache Header Test

When I navigate to /well-known/test.toml, the response is served with the CORS header set and a content-type of "text-plain", and the toml file contents show as plain text in Chrome, which is the desired and expected behavior for both folders.

However when I navigate to /.well-known/test.toml (with the period), there is no CORS header, it shows a content-type of "application/octet-stream", and the toml file downloads instead of showing in the browser.

What exactly is happening here and how can I fix it? Thank you!

CodePudding user response:

After finally asking the right question to Hostinger (thank you MrWhite!), they confirmed that making changes to the /.well-known folder is not possible on a shared hosting plan. Here is the official response I received:

The .well-known directory is server-default, so that is why overriding and making changes to it is not possible on a shared hosting plan, as important data/information is stored there. To make meaningful changes in this directory, you would need root access, which is only available on our VPS plans.

  • Related