.htaccess在公用文件夹中包含index.php和资产 [英] .htaccess to have index.php and assets inside a public folder

查看:98
本文介绍了.htaccess在公用文件夹中包含index.php和资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想像这样划分项目树:

I want to have my project tree divided like this:


  • 应用程序

  • public


    • 资产

    • index.php

    我应该有两个 .htaccess 文件(一个在 root 内部,另一个在 / public 内部)还是一个?

    Should I have two .htaccess files (one inside the root and another inside /public) or just one?

    我的项目位于URL http:// localhost / my-project /

    My project is in the URL http://localhost/my-project/

    我已经将 $ system_path $ application_path 指向其父文件夹,如下所示:

    I have already pointed $system_path and $application_path to their parent folder, like this:

    $system_path = '../system';
    $application_folder = '../application';
    

    但是我可能会丢失一些东西。

    But I might be missing something.

    推荐答案

    在您的 root 目录中只需要一个 .htaccess 文件,输入以下内容:

    You need only one .htaccess file on your root directory, with following entry:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ public/index.php/$1 [L]
    

    这篇关于.htaccess在公用文件夹中包含index.php和资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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