2

我正在尝试将另一个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]
4

1 回答 1

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> 
于 2013-11-05T07:09:11.100 回答