在Laravel 8共享主机上从url中删除public



我已经在子文件夹中托管了Laravel 8应用程序

public_html文件夹内部已创建具有project_name的子文件夹

当我访问它时,

https://maindomain.in/project_name

it

重定向到https://maindomain.in/public/project_name

我已经检查了这些链接

  1. Laravel 7.x-如何删除';公共';来自URL
  2. 从共享主机上的URL Laravel 5.3中删除public

尝试更改.htaccess并将server.php重命名为index.php,但只能通过访问站点

https://maindomain.in/project_name/public此url。

它只读取公共目录的.htaccess

htaccess of root directory

Options -MultiViews -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_URI} !(.css|.js|.png|.jpg|.gif|robots.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

任何解决方案。感谢

最完美的方法是将所有laravel文件移出public_html,然后将所有文件从public文件夹移至public_html

然后转到AppProvidersAppServiceProvider并将以下行添加到register()方法

$this->app->bind('path.public', function() {
return base_path('public_html');
});

保持其他设置,如.htaccess,而不更改

我希望这对有帮助

最新更新