-1

Alright so I've noticed that the .txt files in the root directory of my Drupal install are accessible just using http://drupalsite.com/SOMETHING.txt, but when I try to add other .txt files, I get a 404 when I try to access them from the browser. I've even set these files to have exactly the same user:group and permissions as the .txt files that I can access, and I've tried restarting Apache, but nothing seems to work.

The reason I need this is because I want to use Majestic SEO, which requires you to place a .txt file at the root of your website.

1
  • Do you get a Drupal 404 or a Apache 404 (very simplistic)?
    – Berdir
    Jan 3, 2012 at 22:46

2 Answers 2

1

I use Site verification for tasks like this, although it may not work for this particular case. IIRC it tried the module for a Majestic .txt file, and it added some dummy content for the text file, which the Majestic service did not accept (the file has to be empty). So I uploaded the file directly to the Drupal root via SFTP. I just checked that website, and the Majestic .txt loads normally. I don't see any reason why you would get a 404, other than that the file is indeed not present. I don't think Drupal is to blame, because if the file is present, Apache will serve it. Only if it's not present Drupal starts doing stuff.

So, unless you have done something in .htaccess it should work, and I only have a silly suggestion: double-check that the file is in the correct folder, copy the file name from that directory and paste it in the browser to check.

1
  • Yes, the default .htaccess explictly checks if a actual file exists for the request and only passes the request to Drupal if that's not the case. So that doesn't sound like a Drupal issue...
    – Berdir
    Jan 3, 2012 at 22:46
0

I am not sure I've got exactly what is happening straight, so my explanation may have the details a little off... Browsers are very fussy about opening files due to security risks for users. In Drupal, any file that you want to open must be uploaded to the site using file_save (permanent location), or file_save_upload (temporary location). This process is similar to uploading image files. I have not researched exactly what is happening, but suspect that the file identity is then added to the database and allows Drupal to handle it properly. I am adding files using a custom module function. There may be modules that can do this for you if the Majestic SEO does not load them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.