简体   繁体   中英

Prestashop - GET request to custom PHP file inside module returns 404

I recently developed a module for a Prestashop website, where there is a custom PHP file (not a controller or anything, just plain PHP file) that is used for simple GET requests (generating a PDF).

The path of the file is:

website root dir -> modules -> module_name -> script.php

So, for these requests, I am using localhost/modules/module_name/script.php on my local dev environment (localhost).

However, when deploying the module to the production website (and replacing localhost by the domain name obviously), the website returns a 404 error. Although I am certain that the file exists, at this exact location.

Tried comparing .htaccess files (the one at website's root dir and the one inside modules folder) between my local and production environments, they are exactly the same (except for domain name).

I am able to run other PHP files in the website's root though (eg example.com/script.php can be accessed just fine). Also, the rest of the module (controller, back office page, hooks etc.) works perfectly fine, only this file does not.

Note that "Friendly URLs" are turned on in the Prestashop back office for both environments. What could the issue be? Again, I am 100% sure the URL and the script's path are correct. Is Prestashop blocking the request or something?

Edit: Moving the script to the site's root directory, and using the URL example.com/script.php works fine. But I want to understand why it doesn't work inside the module directory.

Please let me know if you need more information.

Are the web servers of your dev and prod environements the same and configured the same ? There might be some specific configuration on your production web server that prevent you from accessing the file : that would make sense to have some kind of hardened config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM