如何从URL的.html [英] How to remove .html from URL

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

问题描述

你有什么想法如何从一个静态页面的URL删除的.html。另外,我需要重定向任何URL以.html到一个没有(即www.example.com/page.html到www.example.com/page~~V)。

Do you have any idea how to remove .html from the URL of a static page. Also, I need to redirect any url with .html to the one without (ie. 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天全站免登陆