所以我想将我的laravel项目上传到共享主机。 完成后,当我想访问我的网站(只需将其称为www.example.com)时,它会进入/ public目录,我的解决方案是为/ public添加路由作为我的主页,但我不想要它。 p >
所以我的网站路径 p>
/
/ laravel
/ public_html
/ tmp
code> pre>
这是我的.htaccess p>
< IfModule mod_rewrite.c>
< IfModule mod_negotiation.c>
选项-MultiViews
&lt ; / IfModule>
RewriteEngine On
#重定向尾随斜杠如果不是文件夹...
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)/ $ / $ 1 [L, R = 301]
#句柄前控制器...
RewriteCond%{REQUEST_FILENAME}!-d
RewriteCond%{REQUEST_FILENAME}!-f
RewriteRule ^ index.php [L]
#n 处理授权标题
RewriteCond%{HTTP:授权}。
RewriteRule。* - [E = HTTP_AUTHORIZATION:%{HTTP:授权}]
< / IfModule>
code> pre>
\ n 这是我的public_html / index.php p>
<?php
require __DIR __。'/ .. / laravel / bootstrap / autoload.php';
$ app = require_once __DIR __。'/ .. / laravel / bootstrap / app.php ';
$ app-> bind('path.public',function(){
return __DIR __;
});
$ kernel = $ app-> make(Illuminate \ Contracts \ Http \ Kernel :: class);
$ response = $ kernel-> handle(
$ request = Illuminate \ Http \ Request :: capture()
);
$ response-> send();
$ kernel-> terminate($ request,$ response);
code> pre>
div>