[英]Laravel public folder subfolder
我有這樣的laravel文件夾
當我從網址http://example.com/img/img.png訪問時,它可以工作,但是當我訪問諸如http://example.com/img/之類的網站時,我收到禁止訪問403,我需要的是重定向或顯示該信息找不到頁面我的.htaccess像這樣。
選項-MultiViews選項-索引RewriteEngine開
RewriteCond %{HTTP_HOST} ^234\\.123\\.1\\.11 RewriteRule (.*) https://www.example.com/$1 [L,R=301] RewriteCond %{HTTPS} off # First rewrite to HTTPS: RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. RewriteCond %{HTTP_HOST} !^www\\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] </IfModule>
我會說像在routes.php中那樣設置一個簡單的路由,如下所示:
Route::get("/img", function(){
return Redirect::to('/');
});
這應該可以解決問題。 除非您真的沒有其他方法可以編輯.htaccess,否則實際上並不是必需的。
將我的.htaccess更改為
選項-MultiViews選項-索引RewriteEngine開
RewriteCond %{HTTP_HOST} ^28\\.42\\.53\\.24 RewriteRule (.*) https://www.example.com/$1 [L,R=301] RewriteCond %{HTTPS} off # First rewrite to HTTPS: # Don't put www. here. If it is already there it will be included, if not # the subsequent rule will catch it. RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. RewriteCond %{HTTP_HOST} !^www\\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.