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

孤人 提交于 2019-12-12 06:05:40

问题


I want to have my project tree divided like this:

  • application
  • public
    • assets
    • index.php
  • system

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

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

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.


回答1:


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]


来源:https://stackoverflow.com/questions/31705770/htaccess-to-have-index-php-and-assets-inside-a-public-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!