本文介绍了Htaccess删除.php扩展名为.html的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要从网址中删除.php扩展名并用.html
i代替,
To remove .php extension from URL and replaced with .htmli have wrote:
Options -Indexes
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php $1.html [QSA,L]
此工作正常,扩展名已更改,但我收到此消息:
This work fine and i the extension changed, but i get this message:
Not Found
The requested URL /**xxxxxx**.html was not found on this server.
推荐答案
投放 .php
文件作为 .html
,您可以使用以下代码:
To serve .php
files as .html
you can use this code:
Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1.html [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)\.html$ $1.php [L,NC]
这篇关于Htaccess删除.php扩展名为.html的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!