扩展后删除不需要的字符

编程入门 行业动态 更新时间:2024-10-13 02:13:38
本文介绍了扩展后删除不需要的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一些通过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]

更多推荐

扩展后删除不需要的字符

本文发布于:2023-11-02 00:29:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550849.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不需要   字符

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!