Skip to content
Advertisement

Laravel Project on Pleask except homepage other routes are not working

I uploaded files of my Laravel project at Plesk server in httpdocs folder and change necessary permission. Now my homepage is working fine but other routes showing 404 server error ( see screenshot [http://prntscr.com/h54nra][1])

For checking few solutions in different forums and at stackoverflow I also tried to make changes in my .htaccess file but yet unable to resolve. Currently I am using following code hor .htaccess file which is working fine on my localhost

<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}]

Let me know if you find any solution for this

Advertisement

Answer

Since you are using IIS, .htaccess is not involved into redirects to open any of sub-pages except the main page. Instead, redirects should be specified in domain’s web.config file, for example:

<configuration>
<system.webServer>
    <defaultDocument>
        <files>
            <clear />
            <add value="index.php" />
            <add value="default.aspx" />
            <add value="Default.htm" />
            <add value="Default.asp" />
            <add value="index.htm" />
            <add value="index.html" />
        </files>
    </defaultDocument>
    <rewrite>
        <rules>
            <rule name="Imported Rule 1" stopProcessing="true">
                <match url="^(.*)/$" ignoreCase="false" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
            </rule>
            <rule name="Imported 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>
    <httpErrors errorMode="Detailed" />
</system.webServer>

This file should be placed in domain’s httpdocs or httpdocs/public folder, depending on the project configuration. The following tutorials may provide some other details regarding setting up Laravel in IIS: here and here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement