简体   繁体   English

Pleask 上的 Laravel 项目除了主页其他路线都不起作用

[英]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.我在 httpdocs 文件夹中的 Plesk 服务器上上传了我的 Laravel 项目文件并更改了必要的权限。 Now my homepage is working fine but other routes showing 404 server error ( see screenshot [ http://prntscr.com/h54nra][1] )现在我的主页工作正常,但其他路由显示 404 服务器错误(见截图 [ 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.为了检查不同论坛和 stackoverflow 中的几个解决方案,我还尝试在我的 .htaccess 文件中进行更改,但仍无法解决。 Currently I am using following code hor .htaccess file which is working fine on my localhost目前我正在使用以下代码 hor .htaccess 文件,该文件在我的本地主机上运行良好

<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如果您找到任何解决方案,请告诉我

Since you are using IIS, .htaccess is not involved into redirects to open any of sub-pages except the main page.由于您使用的是 IIS,因此 .htaccess 不涉及重定向以打开除主页之外的任何子页面。 Instead, redirects should be specified in domain's web.config file, for example:相反,应该在域的 web.config 文件中指定重定向,例如:

<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.此文件应放置在域的 httpdocs 或 httpdocs/public 文件夹中,具体取决于项目配置。 The following tutorials may provide some other details regarding setting up Laravel in IIS: here and here以下教程可能会提供有关在 IIS 中设置 Laravel 的其他一些详细信息:此处此处

I have faced the same problem in my Plesk server, MY project was done in Laravel.我在我的 Plesk 服务器中遇到了同样的问题,我的项目是在 Laravel 中完成的。 So, I have edited two major files to solve this problem.所以,我编辑了两个主要文件来解决这个问题。 Please find the below changes.请找到以下更改。

i) public -> web.config : 

{
<!--
Rewrites requires Microsoft URL Rewrite Module for IIS
Download: https://www.iis.net/downloads/microsoft/url-rewrite
Debug Help: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite- 
module/using-failed-request-tracing-to-trace-rewrite-rules
-->
<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>

}


ii) public -> .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>

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM