如何更改使用在GoDaddy的Linux主机.htacess文件中的PHP文件扩展名?如何更改、文件扩展名、主机、文件

2023-09-02 00:34:15 作者:北方有旅馆有酒有佳人

我用下面的.htacess规则修改PHP文件扩展HTML:

I am using the following .htacess rules to modify the PHP file extensions to HTML:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.html

我的根放在.htacess文件以及两个PHP文件(page1.php中page2.php中将)。

I placed the .htacess file as well as two PHP files (page1.php and page2.php) in the root.

当我尝试访问使用HTML扩展,而不是(page1.html或page2.html)我得到的404错误信息,说明该页面的PHP文件无法找到。

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

 
精彩推荐
图片推荐