问题
I use a VPS for my website. its based on Laravel framework and I have sat up php54 for my website.
Now when I want to open the website (index.php in the public folder of Laravel), browser just force downloading the file as a application/x-httpd-php54 file type.
I tested adding
AddType application/x-httpd-php54 .php
and AddHandler
to the .htaccess in the public folder.
Neither worked!
I should mention if I enter the ip of my website or enter the name of page it opens the website with no problem.
ip loads mysite
www.example.com loads mysite
example.com/index.php loads mysite
But for example.com
browser forces downloading the file!!!!
回答1:
I noticed that the server document root is XXX and I have a virtual host named example.com with the same document root;
Therefor when I enter the ip, it loaded the document root and it is fine, if I enter the domain name it tries to load the page from virtual host which was unsuccessful.
I deleted the virtual host, because I didn't need virtual host when I could handle my website via the server itself.
Now everything works!
来源:https://stackoverflow.com/questions/24129120/browser-forces-downloading-the-php-page-when-i-want-to-open-the-page