【问题标题】:remove directory url for framework with htaccess使用 htaccess 删除框架的目录 url
【发布时间】:2015-09-20 01:34:51
【问题描述】:

我有这个代码 .htaccess 为 laravel 框架工作

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /testing/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [NC,L]
</IfModule>  

效果很好,但是 框架中的问题 我去网站 example.com/testing

laravel 框架读取 /testing 作为路由的问题

所以我已经对所有路线进行了测试

所以问题是:我怎样才能让 apache 在没有“/testing”的情况下发送 PHP 路由?

【问题讨论】:

    标签: php apache .htaccess laravel


    【解决方案1】:

    只需从范围中排除与 /testing 路径匹配的所有请求。查看htaccess docs

    RewriteEngine On
    RewriteBase /testing/public/
    RewriteCond %{REQUEST_URI} !^/testing$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?$1 [NC,L]
    

    但无论如何您不应该这样做,您将传入的请求重定向到/testing/public/index.php

    您必须按照http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost 中的说明在您的 laravel 应用程序中配置直接指向 /public 文件夹的虚拟主机

    这就是你应该这样做的原因https://security.stackexchange.com/questions/56736/is-web-app-safe-in-not-public-folder

    【讨论】:

      猜你喜欢
      • 2013-05-28
      • 2011-05-15
      • 2021-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多