2013-11-05 132 views
2

我试图另一个重写规则添加到我目前的的.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] 

回答

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> 
+0

非常感谢你,这是解决了最有趣的事 – Curtis

+0

不客气,很高兴它解决了。 – anubhava