.htaccess to have index.php and assets inside a pu

2019-08-30 10:56发布

问题:

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]