我想将php ext.更改为html ext.并禁用对php ext.的直接访问

我想将php ext.更改为html ext.并禁用对php ext.的直接访问,php,.htaccess,Php,.htaccess,有人能帮我吗 我有以下代码,我想将.php改为.html,如果有人试图访问.php,则显示错误404。 如果我们删除“.html”,下面的代码将正常工作。但是我想把php替换成html # Rename Php to html extension RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)\.html$ $1.php #

有人能帮我吗

我有以下代码,我想将.php改为.html,如果有人试图访问.php,则显示错误404。 如果我们删除“.html”,下面的代码将正常工作。但是我想把php替换成html

# Rename Php to html extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)\.html$ $1.php

# Return 404 if original request is .php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]

index.php
在键入
index.html
时打开,如果somebuddy type
index.php
显示错误404。

如果将.php重定向到.html,那么为什么第二条规则会匹配。有意义吗?感谢大家的关注,我不想将.php重定向到.html……如果有人键入index.html,那么只打开网页为什么要删除.php和show.html。从技术上讲,您应该删除SEO友好URL的/index.php,并拥有调用特定php脚本的其他页面,这样它就不会公开脚本,但即使您公开了脚本名称,如果代码是安全的,您也不必担心。如果您将.php重定向到.html,那么为什么第二条规则会匹配。有意义吗?感谢大家的关注,我不想将.php重定向到.html……如果有人键入index.html,那么只打开网页为什么要删除.php和show.html。从技术上讲,您应该删除SEO友好URL的/index.php,并拥有调用特定php脚本的其他页面,这样它就不会公开脚本,但即使您公开了脚本名称,如果代码是安全的,您也不必担心。