2013-11-05 130 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