【问题标题】:How to remove /public/ from url in Slim?如何从 Slim 中的 url 中删除 /public/?
【发布时间】:2019-10-14 03:07:19
【问题描述】:

我把网站扔到主机、服务器上,但我遇到了问题。确切地说,网站网址由以下人员启动:

site.com/public/

我想像这样在没有公众的情况下工作:

site.com/

我用 Slim 3 创建了网站。我有 public 文件夹,其中有 index.php.htaccess 文件。 我的 .htaccess 文件如下所示:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

所以.. 我尝试制作 20 个不同版本的 .htaccess,但它不起作用。如何在没有 /public/ 文件夹的情况下获取 url? 我添加了文件夹结构的照片: folder structure

edit:我忘了一件事,就在我编写网站时,我总是通过 php 内置服务器通过命令运行她:php -S localhost:8888 -t public 并且它的工作没有 /public/

【问题讨论】:

  • 只需将DocumentRoot 设置为您的虚拟主机上的public/ 目录。

标签: php .htaccess slim


【解决方案1】:

试试这个

RewriteEngine On

RewriteRule ^/public/(.*)$ http://www.example.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

【讨论】:

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