phplaravelhostingpleskshared-hosting

Laravel 9 Project Deployed On Plesk Shared host shows the just the main page the other routes not working


I have a shared host on Plesk and I have upload my Laravel Project on it . I have put the project in the root folder and change the document root in hosting settings to public folder that belong to my project

When I open the website the first page works fine but when I try to move to another page it gives me an 404 error which mean that my route doesn't work


Solution

  • I have solved it by adding a

    web.config

    file inside the public folder and put the following code in it :

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
    
        <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>
    
        </system.webServer>
    </configuration>