简体   繁体   English

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

[英].htaccess to have index.php and assets inside a public folder

I want to have my project tree divided like this: 我想这样划分我的项目树:

  • application 应用
  • public 上市
    • assets 资产
    • index.php index.php
  • system 系统

Should I have two .htaccess files (one inside the root and another inside /public ) or just one? 我应该有两个.htaccess文件(一个在根目录内 ,另一个在/public )还是一个?

My project is in the URL http://localhost/my-project/ 我的项目在URL http:// localhost / my-project /中

I have already pointed $system_path and $application_path to their parent folder, like this: 我已经将$system_path$application_path指向其父文件夹,如下所示:

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

But I might be missing something. 但是我可能会缺少一些东西。

You need only one .htaccess file on your root directory, with following entry: 您的目录上只需要一个.htaccess文件,输入以下内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 .htaccess 文件从 url 中删除 index.php 时,我无法使用 Codeigniter 4 访问“/public/assets” - I don't have access to '/public/assets' using Codeigniter 4 when removing index.php from url using a .htaccess file 路由到.htaccess中的/ public和index.php - Routing to /public and index.php in .htaccess CodeIgniter | 将index.php移到公用文件夹 - CodeIgniter | Move index.php to public folder .htaccess将文件夹重写到其他index.php - .htaccess rewrite folder to different index.php htaccess(无重定向)[REWRITEURL](到index.php的文件夹) - htaccess (no redirection) [REWRITEURL] (folder to index.php) .htaccess文件夹到index.php,文件到文件 - .htaccess folder to index.php and file to file 如何在Zend Framework项目中配置.htaccess以仅允许公用文件夹中的index.php - How to configure .htaccess in a Zend Framework project to allow only index.php in public folder 使用.htaccess将index.php放在ubuntu 16.04 LTS的公用文件夹下 - Place index.php under public folder in ubuntu 16.04 LTS using .htaccess .htaccess不允许用户查看没有index.php的文件夹文件 - .htaccess don't allow user to view my folder files that don't have index.php Laravel:将index.php放在公用文件夹的子文件夹中 - Laravel: Put index.php in a subfolder of public folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM