如何在 GoDaddy Linux 主机上使用 .htaccess 文件更改 PHP 文件扩展名? [英] How to change the PHP file extension using .htaccess file on GoDaddy Linux Hosting?
问题描述
我使用以下 .htaccess 规则将 PHP 文件扩展名修改为 HTML:
I am using the following .htaccess rules to modify the PHP file extensions to HTML:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.html
我将 .htaccess 文件以及两个 PHP 文件(page1.php 和 page2.php)放在根目录中.
I placed the .htaccess file as well as two PHP files (page1.php and page2.php) in the root.
当我尝试使用 html 扩展名(page1.html 或 page2.html)访问 PHP 文件时,我收到 404 错误消息,指出无法找到该页面.
When I try to access the PHP files using the html extension instead (page1.html or page2.html) I get the 404 error message stating the page cannot be found.
你能指导我走向正确的方向吗?
Could you please guide me to the right direction?
推荐答案
试试这个:
RewriteEngine on
RewriteRule ^(.*).html$ $1.php
当您访问 page1.html 时,系统将查找:page1.php
when you will access page1.html the system will look for: page1.php
这篇关于如何在 GoDaddy Linux 主机上使用 .htaccess 文件更改 PHP 文件扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!