如何从 URL 中删除 .html? [英] How to remove .html from URL?

查看:34
本文介绍了如何从 URL 中删除 .html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从静态页面的 URL 中删除 .html?

How to remove .html from the URL of a static page?

此外,我需要将带有 .html 的任何 url 重定向到没有它的那个.(即 www.example.com/page.htmlwww.example.com/page ).

Also, I need to redirect any url with .html to the one without it. (i.e. www.example.com/page.html to www.example.com/page ).

推荐答案

感谢您的回复.我已经解决了我的问题.假设我的网页位于 http://www.yoursite.com/html,以下 .htaccess 规则适用.

Thanks for your replies. I have already solved my problem. Suppose I have my pages under http://www.yoursite.com/html, the following .htaccess rules apply.

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /html/(.*).html HTTP/
   RewriteRule .* http://localhost/html/%1 [R=301,L]

   RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /html/(.*) HTTP/
   RewriteRule .* %1.html [L]
</IfModule>

这篇关于如何从 URL 中删除 .html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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