【问题标题】:how to remove public from url in laravel 5.2?如何从 laravel 5.2 中的 url 中删除 public?
【发布时间】:2018-03-14 14:04:48
【问题描述】:

当我访问该网站时,我已经从 url 中删除了 public。我刚刚在根目录中创建了 .htaccess 并包含以下代码:-

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

现在当我访问该网站时,它没有显示为公开并且运行良好。现在的问题是,当我输入我的网站时:- www.example.com/public -> 它仍在打开我想显示 404 页面,谁能帮助我如何做到这一点.. 在此先感谢

【问题讨论】:

标签: php laravel .htaccess laravel-5.2


【解决方案1】:

只需按照以下步骤操作即可:

 1. Rename server.php to index.php in the root folder of your project
 2. Now move the .htaccess file from public folder to the root folder of your project.

就是这样。 :)

【讨论】:

  • 但是当我访问服务器中的图像时,我需要在那里添加公共,这不是一个好方法
【解决方案2】:

如果您使用的是 apache 服务器,则可以借助虚拟主机来完成。如果是 IIS,您可以通过将物理路径目录设置为指向项目的公共目录来实现。

【讨论】:

    猜你喜欢
    • 2019-05-09
    • 2023-03-23
    • 1970-01-01
    • 2016-07-30
    • 2020-06-07
    • 2015-11-17
    • 1970-01-01
    • 2015-01-14
    • 1970-01-01
    相关资源
    最近更新 更多