Laravel 5 –从网址中删除公开 [英] Laravel 5 – Remove Public from URL

查看:74
本文介绍了Laravel 5 –从网址中删除公开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个非常受欢迎的问题,但是我一直无法找到适用于Laravel 5的解决方案.我已经尝试了很长时间从Codeigniter进行迁移,但是这种繁琐的安装过程使我望而却步

I know this is a very popular question but I haven't been able to find a working solution for Laravel 5. I've been trying to migrate from Codeigniter for a long time, but this convoluted installation process keeps putting me off.

我不想运行VM,这在项目之间切换时似乎很尴尬.

I don't want to run a VM, this just seems awkward when switching between projects.

我不想将文档的根目录设置为公用文件夹,这在项目之间切换时也很麻烦.

I don't want to set my document root to the public folder, this is also awkward when switching between projects.

我已经尝试过.htaccess mod_rewrite方法

I've tried the .htaccess mod_rewrite method

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

这只是在configure.php第7610行中给了我一个Laravel NotFoundHttpException.

This just gives me a Laravel NotFoundHttpException in compiled.php line 7610.

前一段时间尝试L4时,我使用了将公用文件夹的内容移到根目录中的方法. L5的结构完全不同,按照相同的步骤完全破坏了Laravel(服务器只会返回空白页).

When I tried L4 a while ago, I used the method of moving the contents of the public folder into the root. The structure of L5 is quite different and following the same steps completely broke Laravel (the server would only return a blank page).

在开发环境中是否有消除公开"的不错的方法,

Is there a decent method of removing 'public' in a development environment that:

  1. 与L5配合使用
  2. 使我可以轻松地在项目之间进行切换(我通常一次可以处理2或3个项目).

谢谢

**我正在使用MAMP和PHP 5.6.2

** I'm using MAMP and PHP 5.6.2

推荐答案

对于Laravel 5:

  1. 将Laravel根文件夹中的server.php重命名为index.php
  2. .htaccess文件从/public目录复制到Laravel根目录 文件夹.
  1. Rename server.php in your Laravel root folder to index.php
  2. Copy the .htaccess file from /public directory to your Laravel root folder.

就是这样!

这篇关于Laravel 5 –从网址中删除公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆