使用.htaccess将根目录重定向到文件夹


Redirect root to folder with .htaccess

我有以下项目结构:

/app
    /api
    /css
    /img
    /js

我想将所有请求从/app文件夹重定向到子文件夹/api。我尝试了以下.htaccess代码,但没有成功:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /api/index.php/$1 [L]

我的Apache已启用Mod_Rewrite。知道吗?

将其放入/api/.htaccess文件:

RewriteEngine on
RewriteBase /app/
RewriteRule ^((?!api/index'.php/).+)$ api/index.php/$1 [NC,L,R]