2017-02-14 47 views
1

我有一個php_value auto_prepend_file在我使用絕對路徑的htaccess中......這在我的本地主機上,但是當我在web服務器上傳時,我需要不同的絕對路徑。 ..htaccess模擬rewritecond IF..ELSE對ip地址

#php_value auto_prepend_file "/path/to/web/server/auto_prepend.php" 
php_value auto_prepend_file "/path/to/local/server/auto_prepend.php" 

然後,我需要這樣的東西

if (ipaddress == serverip) 
    php_value auto_prepend_file "/path/to/web/server/auto_prepend.php" 
else 
    php_value auto_prepend_file "/path/to/local/server/auto_prepend.php" 
+0

你使用的是什麼版本的Apache? – starkeen

+0

apache版本是2.4 – FireFoxII

回答

1

在Apache 2.4,你可以做類似如下:

<if "%{REMOTE_ADDR} ='yourip'"> 
php_value auto_prepend_file "/path/to/file/" 
</if> 
<else "%{REMOTE_ADDR} !='yourip'"> 
#Your php_value directive 
</else> 

我還沒有測試過這個。

+1

不工作....我有內部服務器錯誤 - **編輯**謝謝,解決更改ELSE ELSEIF – FireFoxII