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

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

问题描述

如何从静态页面的网址中删除 .html

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

另外,我需要将任何带有 .html 的URL重定向到没有它的URL。 (即 www.example.com/page.html www.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天全站免登陆