【发布时间】:2021-01-11 14:31:23
【问题描述】:
想要使用 DDEV 进行本地开发,并且我有一个包含遗留内容的站点,需要在扩展名为 .html 的页面上运行 php。在其他测试环境中,我在 .htaccess 中使用了不同的行来启用它。使用我的 ddev 测试环境,我还不知道什么是有效的。
更新 以下是我在 .htaccess 中尝试过的行(单独或组合取消注释):
#AddType application/x-httpd-php .html .htm
#AddHandler application/x-httpd-php .htm .html
#AddType application/x-httpd-php7 .html .htm
#AddHandler application/x-httpd-php7 .htm .html
#AddHandler x-httpd-php .htm .html
#AddType x-httpd-php .html .htm
#AddType x-httpd-php7 .html .htm
#AddHandler x-httpd-php7 .htm .html
#AddType x-httpd-php73 .htm .html
#AddHandler x-httpd-php73.htm .html
#AddHandler x-httpd-php7-3 .htm .html
#AddType application/x-httpd-php73 .html .htm
#AddType application/x-httpd-php7-3 .html .htm
#AddHandler application/x-httpd-php7-3 .htm .html
我还尝试使用以下内容更新 .ddev/apache/apache-site.conf:
<FilesMatch ".html$">
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>
或
<FilesMatch ".+\.html$">
SetHandler applicaiton/x-httpd-php
</FilesMatch>
但我承认这不是我熟悉的东西,所以可能没有完全正确。
macOS Big Sur, ddev1.16.5 with php7.3, ddev webserver_type: apache-fpm.
有什么建议吗?谢谢!
【问题讨论】:
-
你没有提到你是否在 ddev 中使用
webserver_type: apache-fpm。默认是 nginx-fpm,它不会尊重你的 .htaccess... -
谢谢@rfay - 我设置了 webserver_type: apache-fpm,很好。但是,问题仍然存在......我试过了:`#AddType application/x-httpd-php .html .htm #AddHandler application/x-httpd-php .htm .html #AddType application/x-httpd-php7 .html .htm #AddHandler application/x-httpd-php7 .htm .html AddHandler x-httpd-php .htm .html AddType x-httpd-php .html .htm #AddType x-httpd-php7 .html .htm #AddHandler x-httpd-php7 .htm .html #AddType x-httpd-php73 .htm .html #AddHandler x-httpd-php73.htm .html `
-
我还尝试使用以下内容更新 .ddev/apache/apache-site.conf:
SetHandler "proxy:fcgi://php:${APACHE_FCGI_HOST_PORT}" 或SetHandler applicaiton/x-httpd-php 但不可否认,这不是我熟悉的东西,所以可能不太正确?此外,apache-site.conf 被 ddev stop/start 覆盖,因此在编辑 .conf 后使用“ddev exec apachectl -k graceful”进行测试,但应该能够保留这些更改吗?再次感谢! -
哈哈我看到了允许site.conf的自定义保留的行!很明显,我还在适应……