如何在GoDaddy Linux Hosting上使用.htaccess文件更改PHP文件扩展名? [英] How to change the PHP file extension using .htaccess file on GoDaddy Linux Hosting?

查看:61
本文介绍了如何在GoDaddy Linux Hosting上使用.htaccess文件更改PHP文件扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下.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 Hosting上使用.htaccess文件更改PHP文件扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆