【发布时间】:2013-11-14 00:02:22
【问题描述】:
我基本上已经为自己开发了一个自定义框架,它使用以下 .htaccess 行从 index.php 运行所有内容
RewriteRule .* index.php [QSA,L]
我现在已经开发了一个 REST API,我需要通过相同的服务器/根目录运行,我尝试将以下 URL 添加到 .htaccess 中,只是提示使用自定义 404 我已集成到我的自定义框架,所以基本上它忽略了这一行,只是尝试将 RewriteRule 用于我的自定义框架
RewriteRule /api/v1/(.*)$ myAPI.php?request=$1 [QSA,NC,L]
我怎样才能得到它,这样我的 API url 就不会作为查询传递给我的其他 RewriteRule
我的 .htaccess 如下所示
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
AddType "text/html; charset=UTF-8" html
AddType "text/plain; charset=UTF-8" txt
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# if file not exists
RewriteCond %{REQUEST_FILENAME} !-f
# if dir not exists
RewriteCond %{REQUEST_FILENAME} !-d
# avoid 404s of missing assets in our script
RewriteCond %{REQUEST_URI} !^.*\.(jpe?g|png|gif|css|js)$ [NC]
# rest api url
RewriteRule ^api/v1/(.*)$ /myAPI.php?request=$1 [QSA,NC,L]
# core framework url rewriting
RewriteRule .* index.php [QSA,L]
</IfModule>
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite