开发者

Using mod_rewrite to remove file extensions

I am looking for a way to remove incoming links that contain file extensions, such as .htm, .html, and .php and to send a 302 response so that the referrer knows to update their links.

For example, www开发者_如何学C.acmeinc.com/projects.html would redirect to www.acmeinc.com/projects and send a 302 response.


Something like this should do the magic:

RewriteRule ^([^\.]+)\. $1 [R=302,L]

This rule is only valid for www.acmeinc.com/projects.html and not for www.acmeinc.com/projects.seconddot.html. If you'd like to rewrite only certain extensions, use this rule.

RewriteRule ^([^\.]+)\.(html|php|js|foobar) $1 [R=302,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜