如何.html从静态页面的URL中删除?
此外,我需要将任何网址重定向到没有网址的网址.html.(即www.example.com/page.html到www.example.com/page).
今天早些时候,我正在帮助一个.htaccess用例的人,并提出了一个有效的解决方案,但我自己无法弄明白!
他希望能够:
index.php?id=3&cat=5index/3/5/index.php?id=3&cat=5最后两个步骤相当典型(通常来自用户index/3/5首先进入),但第一步是必需的,因为他的网站中仍然有一些旧格式的链接,无论出于何种原因,都无法更改它们.所以他需要支持这两种 URL格式,让用户总是看到美化的格式.
经过多次考验后,我们想出了以下.htaccess文件:
RewriteEngine on
# Prevents browser looping, which does seem
# to occur in some specific scenarios. Can't
# explain the mechanics of this problem in
# detail, but there we go.
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
# Hard-rewrite ("[R]") to "friendly" URL.
# Needs RewriteCond to match original querystring.
# Uses "?" in target to remove original querystring, …Run Code Online (Sandbox Code Playgroud)