我正在尝试将另一个 RewriteRule 添加到我当前的.htaccess中,以下是.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]
# core framework url rewriting
RewriteRule .* index.php [QSA]
<IfModule mod_rewrite.c>
然后我尝试在RewriteRule .* index.php
之前添加以下内容但它仍然被完全忽略
RewriteRule ^api/v1/(.*)$ /myAPI.php?request=$1 [QSA,NC,L]
答案 0 :(得分:1)
这就是你应该如何使用新规则保存.htaccess:
Options +FollowSymlinks -MultiViews
AddType "text/html; charset=UTF-8" html
AddType "text/plain; charset=UTF-8" txt
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# API rule
RewriteRule ^api/v1/(.*)$ /myAPI.php?request=$1 [QSA,NC,L]
# 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]
# core framework url rewriting
RewriteRule ^ index.php [L]
<IfModule mod_rewrite.c>