2016-12-05 61 views
2

我正在嘗試一整天來完成這項工作,但我無法讓它正常工作。 我使用CMS十月,從而產生以下.htaccess文件:.htaccess中的白名單php腳本

​​

我也有contact.php文件位於/表格/目錄。我想要的是通過使用POST時執行contact.php。與wordpress或joomla我沒有遇到這樣的問題。 另外,有沒有一個很好的學習htaccess的教​​程?

回答

0

這個工作嗎?當文件名爲contact.php時,我添加了條件。這裏是教程改寫:https://httpd.apache.org/docs/current/mod/mod_rewrite.html

## 
## Block all PHP files, except index 
## 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteCond %{REQUEST_FILENAME} \.php$ 
RewriteCond %{REQUEST_FILENAME} !^contact.php$ ## this is new condition 
RewriteRule !^index.php index.php [L,NC] 
+0

謝謝您時間,不幸的是它似乎沒有工作 - 當我試圖直接通過瀏覽器或通過POST從聯繫表單中獲得403錯誤時:/ – engray

+0

如果你刪除完整的「##阻止所有的PHP文件,除了索引」然後工作? – Fanda36

+0

或添加此項(在##阻止所有PHP文件之前,索引除外): – Fanda36

0

添加行到最後一行上述標題White listed folders部分與RewriteRule

RewriteCond %{REQUEST_FILENAME} !your-file\.php

註釋掉與標題部分Block all PHP files, except index