Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 从Laravel 5.4-CentOS 6的url中删除index.php_Linux_.htaccess_Laravel 5_Laravel 5.4_Centos6 - Fatal编程技术网

Linux 从Laravel 5.4-CentOS 6的url中删除index.php

Linux 从Laravel 5.4-CentOS 6的url中删除index.php,linux,.htaccess,laravel-5,laravel-5.4,centos6,Linux,.htaccess,Laravel 5,Laravel 5.4,Centos6,关于这个问题,我在互联网上尝试了几乎所有的解决方案 我已将我的Laravel项目从Windows 10移动到linux CentOS 6。我试图以两种不同的方式改变项目结构,但都面临这个问题 我正在尝试从[www.example.com]/index.php/[routes url]中删除index.php。我无法访问root或sudo命令,因为此项目正在大学服务器中安装。但我可以请求IT管理员处理需要root访问权限的任务 我目前在/home/cs4/username(文件夹)中。我目前的项目

关于这个问题,我在互联网上尝试了几乎所有的解决方案

我已将我的Laravel项目从Windows 10移动到linux CentOS 6。我试图以两种不同的方式改变项目结构,但都面临这个问题

我正在尝试从
[www.example.com]/index.php/[routes url]
中删除index.php。我无法访问root或sudo命令,因为此项目正在大学服务器中安装。但我可以请求IT管理员处理需要root访问权限的任务

我目前在
/home/cs4/username(文件夹)
中。我目前的项目结构是:

blog (folder)
 - contains all the Laravel framework files other than public folder

 public_html (folder)
 - contains all the files of laravel public folder plus 
 - .htaccess file created
.htaccces文件包含以下代码:

 # Redirect Trailing Slashes...
 #RewriteRule ^(.*)/$ $1 [L,R=301]

 RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
 RewriteCond %{REQUEST_URI} !/system/.* [NC]
 RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

 # Handle Front Controller...
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 #RewriteRule ^ index.php [L]
 RewriteRule ^(.*)$ /index.php/$1 [L]
我已经替换了public_html文件夹中的index.php文件的两行

从这些

require __DIR__.'/../bootstrap/autoload.php';
 $app = require_once __DIR__.'/../bootstrap/app.php';

问题是加载项目,但对于所有其他url,我必须添加index.php,例如:而不是类似地添加所有其他url

我还尝试将整个项目放在public_html文件夹中,目录结构是:

public_html
 -entire project files and folders
 -public folder
但有两个问题:

暴露了所有服务器文件,如:.env和其他代码,导致安全风险

我被迫在url中使用public/index.php


例如:与所有其他url类似。

你找到解决方案了吗?@Michel它与.htaccess有关。我不确定是什么使它起作用。我只记得我必须在linux文件夹中的某个地方设置虚拟主机,然后我从laravel项目中取出公用文件夹,并将其放在项目文件夹旁边。比如:
public folder和myApp folder
我还必须将server.php文件中的url更改为指向项目文件夹外的public folder。然后,公用文件夹被授予对所有文件和文件夹的读写和执行775 Chmod的完全访问权限。我也被相同的权限绊倒了!如果您能分享您所做的一切,这将非常有帮助。@Michel这些步骤是:@Michel allow override all works。有关VirtualHost的信息,请查看我共享的同一链接中的
smcjones
解决方案
public_html
 -entire project files and folders
 -public folder