Removing unwanted characters after extension

后端 未结 1 679
执笔经年
执笔经年 2021-01-24 08:22

I have pages that are called via a query strung from a cgi.

xyz.cgi?page=abc.html

The problem that I have is that I get bot requests for pages

相关标签:
1条回答
  • 2021-01-24 08:46

    You can use the following rule to remove chars after the html extension :

     RewriteRule ^(.+\.html).+$ /$1 [L,R]
    

    This will redirect

    /foo.htmlchars
    

    to

    /foo.html
    

    Or

    RedirectMatch ^/(.+\.html).+$ /$1
    

    EDIT :

    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]
    
    0 讨论(0)
提交回复
热议问题