Php 如何在/var/www/html/blog/for laravel 5.6上设置htaccess
我的目标Php 如何在/var/www/html/blog/for laravel 5.6上设置htaccess,php,mod-rewrite,laravel-5,Php,Mod Rewrite,Laravel 5,我的目标 我想设置DocumentRoot”/var/www/html“ 我的laravel项目位于/var/www/html/blog 文件/var/www/html/blog/routes/web.php设置路由 Route::get('demo','DemoController@index'); 我需要请求调用/blog/public/demo调用DemoController 问题: -如果我想使用URL替换/blog/demo替换/blog/public/demo,如何在/var/www
DocumentRoot”/var/www/html“
/var/www/html/blog
/var/www/html/blog/routes/web.php
设置路由
Route::get('demo','DemoController@index');代码>
/blog/public/demo
调用DemoController
-如果我想使用URL替换
/blog/demo
替换/blog/public/demo
,如何在/var/www/html/blog/
处编写.htaccess?创建一个.htaccess文件,如果该文件不存在,请创建您的Laravel根目录
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
重新启动发动机
重写规则^(.*)$public/$1[L]
试试这个。希望它能帮助您。[root@xxxxxx~]#curl-I HTTP/1.0 404未找到日期:2018年2月28日星期三10:15:50 GMT服务器:Apache/2.4.6(CentOS)PHP/7.1.14 X-Powered-By:PHP/7.1.14缓存控制:无缓存,私有连接:关闭内容类型:text/html;字符集=UTF-8