.htaccess 如何重定向URL末尾带有公共文件名的页面?

.htaccess 如何重定向URL末尾带有公共文件名的页面?,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,我想重定向以相同表达式结尾的不同页面,例如: /something.php 我有以下网址: /truc/machin/something.php /truc/tous-56/something.php /truc/machin/tous-56/something.php 我不想在.htaccess中有太多的行,我想通过正则表达式的通用规则来解决这个问题 您能否帮助我找到正确的表达式,以便在线重定向my.htaccess中的所有内容?这应该适用于您: RewriteEngine On Rewr

我想重定向以相同表达式结尾的不同页面,例如:

/something.php
我有以下网址:

/truc/machin/something.php
/truc/tous-56/something.php
/truc/machin/tous-56/something.php
我不想在
.htaccess
中有太多的行,我想通过正则表达式的通用规则来解决这个问题


您能否帮助我找到正确的表达式,以便在线重定向my
.htaccess
中的所有内容?

这应该适用于您:

RewriteEngine On
RewriteRule ^(.*)/something.php$ /somethingelse.php [R=301,L]
如果
something.php
在url中,它会将
something.php
重定向到
somethingelse.php