Thursday, March 19, 2020

Laravel Or PHP website downloading file

Laravel Or PHP website downloading file


Laravel Or PHP website downloading file instead of execution Fixed Solution

If you are facing the below problems then I have a solution that's work for me. Below is the check list of problems.
  1. PHP files are DOWNLOADING instead of  EXECUTING on nginx
  2. Laravel Application is downloading index.php instead of execution on MAMP

Solution:

 Actually In some cases developer first deployed website on own hosting for demo purpose or for
testing purpose and then move to client hosting. When developer moved directly from one hosting to
another then they are start getting this problem like some one visit website and download the `index.php`  file or any other file like download without any extension.

In short this is the .htacess problem just look in your root or `public_html`   `.htacess`  file and fixed your problem. How I did fix my problem I am posting below see clearly it will help you definitely.

Before

Look at my `.htacess` file 

<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteRule ^(.*)$ public/$1 [L]

</IfModule>

# Hide a specific file

<Files .env>

    Order allow,deny

    Deny from all

</Files>

# php -- BEGIN cPanel-generated handler, do not edit

# Set the “ea-php73” package as the default “PHP” programming language.

<IfModule mime_module>

  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml

</IfModule>

# php -- END cPanel-generated handler, do not edit 

After 


<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteRule ^(.*)$ public/$1 [L]

</IfModule>

# Hide a specific file

<Files .env>

    Order allow,deny

    Deny from all

</Files>


You have to remove the red code as I posted from your `.htacess` After modify the `.htacess`
file Just check first in private browser by pressing `cltr+shift+n`  and visit your site. Hopefully your website will be come online. In my case I did like that I explained and get success.

 If you need any help regarding this just post your comments. I will quickly solve for you. Thanks for reading.

0 comments:

Post a Comment

Please don't enter any spam link in the comment box.