简体   繁体   English

Laravel公用文件夹子文件夹

[英]Laravel public folder subfolder

I have laravel folder like this 我有这样的laravel文件夹

  • app 应用
  • vendor 供应商
  • bootstrap 引导
  • public 上市
    • folder
    • img IMG

when I access from url http://example.com/img/img.png it works But when i access like http://example.com/img/ I get Forbidden 403, What I need is to redirect or to show that page not found My .htaccess looks like this. 当我从网址http://example.com/img/img.png访问时,它可以工作,但是当我访问诸如http://example.com/img/之类的网站时,我收到禁止访问403,我需要的是重定向或显示该信息找不到页面我的.htaccess像这样。

Options -MultiViews Options -Indexes RewriteEngine On 选项-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> 

I'd say setup a simple route like in the routes.php like so: 我会说像在routes.php中那样设置一个简单的路由,如下所示:

Route::get("/img", function(){
    return Redirect::to('/');
});

this should do the trick. 这应该可以解决问题。 editing your .htaccess isn't really nessecary unless you really have no other way of doing this kind of things 除非您真的没有其他方法可以编辑.htaccess,否则实际上并不是必需的。

Changed my .htaccess to 将我的.htaccess更改为

Options -MultiViews Options -Indexes RewriteEngine On 选项-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> 

Source: 资源:

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

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