重写规则重新命名网址是什么? [英] RewriteRule to rename URL?
本文介绍了重写规则重新命名网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个关于重写规则的两个问题,但他们都是密切相关的,所以我希望这是好的。我问他们两个在一个单一的岗位。
I have two questions regarding RewriteRule, but they're both closely related so I hope it's OK I ask them both in a single post.
首先,我想脱光尾随 index.html的
的任何URL的结尾,例如:
The first is that I'd like to strip trailing index.html
's from the end of any URL, e.g.:
http://www.example.com/index.html -> http://www.example.com/
二是要显示在浏览器的地址栏中的URL http://www.example.com/contact/
所有以下网址:
http://www.example.com/contact/
http://www.example.com/contact/index.html
http://www.example.com/contact/success.html
http://www.example.com/contact/failure.html
例如,如果用户被重定向到 http://www.example.com/contact/success.html
我想该网页显示给他们,但 http://www.example.com/contact/
作为URL。这可能吗?
For example, if the user is redirected to http://www.example.com/contact/success.html
I'd like that page to be displayed to them, but with http://www.example.com/contact/
as the URL. Is that possible?
推荐答案
对于指数:
RewriteRule ^(.*)/index.html /$1/ [R]
二:
RewriteRule ^contact/(success|failure)\.html /contact/ [L]
这篇关于重写规则重新命名网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文