我有一个如下所示的文件夹目录。该请求来自访问,如果URL中包含API字符串,则我想在请求上写一个条件,然后重定向到api/index.php
,否则重定向到web/index.php
。
root
+ api
+index.php
+web
+index.php
+.htaccess
我现在的htaccess为
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^(.*)api(.*)$
RewriteRule ^(.*)$ api/index.php/$1 [L]
RewriteCond %{REQUEST_URI} ^/.*
RewriteRule ^(.*)$ web/$1 [L]
RewriteCond %{REQUEST_URI} ^/(assets|css|js|img|uploads)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ /web/css/$1 [L]
RewriteRule ^js/(.*)$ /web/js/$1 [L]
RewriteRule ^img/(.*)$ /web/img/$1 [L]
RewriteRule ^uploads/(.*)$ /web/uplods/$1 [L]
RewriteRule ^frontAssets/(.*)$ /web/frontAssets/$1 [L]
RewriteCond %{REQUEST_URI} !^/web/(assets|css|js|img|uploads)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ web/index.php