PHP 到 HTML 请求而不更改浏览器 URL


php to html request without changing browser url

我的网站正在使用URL中的.html扩展名。但是我想将其更改为.php。但是页面不起作用。url 是否正在使用.php扩展名并且服务器将其视为.html请求

很可能你没有Apache设置来解析PHP文件。除非我错过了问题是什么?您也想重命名.html文件以.php并且仍然让它们工作?

默认情况下,在 Ubuntu 12.04 中,PHP 是通过mods-available中的php5.conf文件启用的,该文件应如下所示。

<IfModule mod_php5.c>
    <FilesMatch "'.ph(p3?|tml)$">
    SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "'.phps$">
    SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off
        </Directory>
    </IfModule>
</IfModule>