2013-04-24 120 views
2

我有一個.htaccess文件,其內容如下阿帕奇國防部重寫條件

RewriteEngine on 
# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

#RewriteCond %{REQUEST_URI} (\/image\/) 
#RewriteRule . image.php 

RewriteRule . index.php 

什麼是指示Apache發送請求,如果/圖像請求URL中發現/於image.php正確的方法,如果沒有,我想index.php處理請求?

回答

1

要處理請求而不提供重定向,只要您的image.php文件配置爲處理請求,就可以執行此類操作。如果您發現以「image」開頭的字符串加載image.php文件和stop processing the rest of the htaccess file,我們告訴Apache。

RewriteEngine on 
#If we find image, then load image.php 
RewriteRule ^/?image image.php [L] 

# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule .* index.php 
+0

完美,正是我需要的。謝謝 – 2013-04-24 15:46:32

+0

不客氣。 – 2013-04-24 15:47:24