vendredi 17 juin 2016

Laravel 5.2 localhost not working unless php artisan serve works

I have been battling this for two days. I just go a VM(Windows server 2012) in azure an i configured php and mysql to work with my IIS. everything works fine and php works as expected.

I installed a laravel project and when i navigate to it localhost/myproject/public it worked properly.

So for my work flow i code on my local system, and push it to a repo on github and pull the changes on the virtual machine. this worked initially, But now when visit any other page except the / page which is on IP_ADDRESS/myproject/publici realised that it just shows a 500 error.

when i log into the virtual machine and and check it via localhost, it does the same thing. the strange thing is when i run php artisan serve on the folder, it works perfectly and the routes and links work. But what is even stranger is that, any page i open when im using php artisan serve, now works properly when i use localhost/myproject/public. ONLY the pages i accessed while using php artisan serve.

What have i done?

i've given full access to the /storage and bootstrap folder

No error logs appear in the storage/logs/laravel.log folder

This is my /public/web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Rule 1" stopProcessing="true">
              <match url="^(.*)/$" ignoreCase="false" />
              <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
            </rule>
            <rule name="Rule 2" stopProcessing="true">
              <match url="^" ignoreCase="false" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php" />
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration> 

This is my /public/.htaccess file

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

    RewriteEngine On

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

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

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

Please any help or suggestions would be greatly appreciated



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire