本文介绍了扩展后删除不需要的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些通过cgi进行的查询调用的页面。
I have pages that are called via a query strung from a cgi.
xyz.cgi?page=abc.html我遇到的问题是,我收到了对确实存在的页面的机器人请求,但该请求具有 .html 之后的字符,结果是404。
The problem that I have is that I get bot requests for pages that do exist, but the request has characters after the .html and the result is a 404.
.htaccess 删除 .html 扩展名之后的所有内容?
Is there a way in .htaccess to strip off everything after the .html extension?
推荐答案您可以使用以下规则在html扩展名后删除字符:
You can use the following rule to remove chars after the html extension :
RewriteRule ^(.+\.html).+$ /$1 [L,R]这将重定向
/foo.htmlchars至
/foo.html或
RedirectMatch ^/(.+\.html).+$ /$1编辑:
重定向 /xyz.cgi?page=foo.html字符到 /xyz.cgi?page=foo.html ,您可以使用以下命令:
To redirect /xyz.cgi?page=foo.htmlchars to /xyz.cgi?page=foo.html you may using the following :
RewriteEngine on RewriteCond %{THE_REQUEST} /xyz\.cgi\?page=(.+\.html).+\sHTTP [NC] RewriteRule ^ /xyz.cgi?page=%1 [L,R]更多推荐
扩展后删除不需要的字符
发布评论