简体   繁体   English

使用.htaccess从URL删除文件夹

[英]Using .htaccess to remove folder from URL

I have a Laravel app, and the document root of host is configured at Laravel root folder (upper directory of public). 我有一个Laravel应用程序,并且主机的文档根目录是在Laravel根文件夹(公用的上层目录)中配置的。

I tried the following .htaccess to silently rewrite URLs, but it keeps redirecting me to /public, instead of showing domain URL and rewriting it to /public 我尝试使用以下.htaccess默默地重写URL,但是它始终将我重定向到/ public,而不是显示域URL并将其重写为/ public

RewriteEngine On
RewriteRule ^(.*)?$ /public$1 [L,NC]

I want to visit example.com and see my Laravel app, not redirecting user to example.com/public . 我想访问example.com并查看我的Laravel应用,而不是将用户重定向到example.com/public

This will help you definitely : Removing the /public segment in a Laravel 4 app 这绝对可以为您提供帮助 :在Laravel 4应用中删除/ public段

http://creolab.hr/2013/03/removing-the-public-segment-in-a-laravel-4-app/ http://creolab.hr/2013/03/removing-the-public-segment-in-a-laravel-4-app/

Create a front controller in the document root, call it index.php. 在文档根目录中创建一个前端控制器,将其称为index.php。 Use this front controller to invoke the front controller in the public folder. 使用此前端控制器可以调用公用文件夹中的前端控制器。 Make sure you add the .htaccess to that document root prohibiting all sensitive data from being accessed. 确保将.htaccess添加到该文档根目录,以禁止访问所有敏感数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM