本文介绍了.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和资产
发布评论