.htaccess 删除URL中的尾随文本

.htaccess 删除URL中的尾随文本,.htaccess,url,.htaccess,Url,我需要删除URL末尾的文本。URL的外观如下所示: www.test.co.za/news/cat/index-mobile.html www.test.co.za/page-name/index-mobile.html 我需要从URL中删除index-mobile.html 提前感谢。您可以在站点根目录中使用此规则。htaccess: RewriteEngine On RewriteCond %{THE_REQUEST} \s/+(.*)/index-mobile\.html\s [NC]

我需要删除URL末尾的文本。URL的外观如下所示:

  • www.test.co.za/news/cat/index-mobile.html
  • www.test.co.za/page-name/index-mobile.html
  • 我需要从URL中删除index-mobile.html


    提前感谢。

    您可以在站点根目录中使用此规则。htaccess:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \s/+(.*)/index-mobile\.html\s [NC]
    RewriteRule ^ /%1? [R=301,L,NE]
    
    # rest of your rules ho here