.htaccess在公用文件夹中包含index.php和资产

编程入门 行业动态 更新时间:2024-10-28 02:34:56
本文介绍了.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 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和资产

本文发布于:2023-07-12 07:24:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1096849.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:资产   文件   夹中   htaccess   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!