简体   繁体   中英

.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
  • 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.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM