0
我有像Ucp.php Somesite.php文件,我想爲nginx創建一個重寫規則。這不是問題。使用nginx阻止直接訪問php文件(僅重寫)
但我也想阻止直接訪問這些php文件,以便enetring http://mysite.com/Ucp.php將返回404 Not Found。
有一個解決方案爲Apache(使用THE_REQUEST),但我怎麼能在nginx上做到這一點?
server
{
listen 80;
server_name site.com;
root /home/site/public_html;
index Main.php;
rewrite ^/SomeAddr/$ /SomeAddr.php last;
rewrite ^/SomeOtherAddr/$ /SomeOtherAddr.php last;
location ~ \.php$
{
fastcgi_pass unix:/var/run/php-fpm/site_com.sock;
include fastcgi.conf;
}
include security.conf;
}
都能跟得上?它阻止每個php文件,即使它重寫。你沒看過我的文章嗎? – peku33 2013-05-14 14:12:32
你對你的配置一言不發......你用過fastcgi_pass了嗎? – Jack 2013-05-14 20:16:25
是的,我當然是。我想改變的唯一事情是阻止網址包含.php – peku33 2013-05-15 11:39:40