Nginx如何配置可以让.html后缀的文件当php动态文件执行

来源:互联网 发布:关于加强网络信息安全 编辑:程序博客网 时间:2024/05/20 21:45

有两种方式修改nginx配置文件可以实现。

方式一:打开你的网站的nginx配置文件,然后找到:“location ~ \.php$ {”,再把其中的\.php修改为:“\.php|\.html”,保存后重启nginx即可。

方式二:同上,打开配置文件找到:“location ~ \.php$ {”,然后把location整段复制,在下面粘帖上,再把\.php修改为\.html,保存后重启nginx即可生效。

上述两种方式的配置示例代码如下:

示例一:

location ~ \.php|\.html$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /webs$fastcgi_script_name; include fastcgi_params; }

示例二:

location ~ \.html$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /webs$fastcgi_script_name; include fastcgi_params; }


0 0