繁体   English   中英

使用.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]

暂无
暂无

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

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