2

I am trying to make working laravel 5.4 on shared hosting. I am using below code of .htaccess file, but it start downloading files instead of showing content. below is my .htaccess code.

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]

RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
# Use PHP70 as default
AddHandler application/x-httpd-php70 .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/php70/lib
</IfModule>

I don't know, where I am getting wrong.

Faisal Ahsan
  • 928
  • 1
  • 12
  • 22
  • Or this? https://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-but-the-code-shows-in-the-browser-source-code – Nico Haase Feb 16 '22 at 10:52

2 Answers2

1

Probably dublicated

Apache is downloading php files instead of displaying them

PHP files are downloaded by browser instead of processed by local dev server (MAMP)

Make sure it's Apache and not Nginx

If it's nginx the answer may be this

Nginx serves .php files as downloads, instead of executing them

Community
  • 1
  • 1
0

You have to change in your .htaccess file

Here is mine .htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
<IfModule mime_module>
        AddHandler application/x-httpd-ea-php72 .php .php7 .phtml 
</IfModule>

Remove the last "IfModule - mime_module" part and restart your wamp or xampp server

Imtiaze
  • 43
  • 9