Htaccess删除.php扩展名为.html的URL [英] Htaccess Removing .php extension to .html make an URL Not found

查看:77
本文介绍了Htaccess删除.php扩展名为.html的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要从网址中删除.php扩展名并用.html
i代替,

To remove .php extension from URL and replaced with .html i 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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