簡體   English   中英

Laravel 未檢測到公用文件夾中的文件

[英]Laravel not detecting files from public folder

大家好,下面是公用文件夾中的代碼.htaccess ...

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    Options +FollowSymLinks
    RewriteRule ^ index.php [L]
    # Redirect Trailing Slashes...
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
</IfModule>

好像我在公共文件夾中有一些圖像...“顯示未找到錯誤消息”...無論如何要解決這個問題???

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

嘗試將其更改為此,確保此.htaccess位於公用文件夾中。 在應用程序內部,我還有另一個.htaccess

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]

RewriteCond %{HTTP:Authorization} .

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

laravel正常工作!

試試這段代碼。 它將在共享服務器或其他服務器中完美運行。

用於修復此問題。 我做了一些步驟:

  1. 將所有文件從Public Folder復制到root Folder

  2. 更改index.php中的路徑意味着將其替換為'../'"/"

  3. 更新。 htaccess文件與此代碼。

  4. 我還添加了隱藏env文件的代碼。 如果您不添加該代碼,那么任何人都可以看到您的env文件。

     <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 [LR=301] #RewriteCond %{REQUEST_URI}.(\.css|\.js|\.png|\.woff|\.woff2|\.jpg|\.gif|robots\.txt)$ [NC] RewriteCond %{REQUEST_URI}.(\.svg|\.woff|\.woff2|\.ttf|\.css|\.js|\.png|\.jpg|\.gif|\.pdf|\.jpeg|\.docx|robots\,txt)$ [NC] RewriteCond %{REQUEST_FILENAME}.-d RewriteCond %{REQUEST_FILENAME}.-f RewriteRule ^ index.php [L] RewriteCond %{REQUEST_FILENAME}.-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/public/ RewriteRule ^(css|js|images|admin|userimage|ckedit_images|video|thumbnail|fonts|amenities-pic|img|propert|property_video|vendor|photos|files|doc|flags|1x1|4x3)/(.*)$ public/$1/$2 [L,NC] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
     #hide a Specifuc Laravel.env File <Files.env> order allow,deny Deny from all </Files>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM