gpt4 book ai didi

.htaccess - Htaccess 从末尾的数字重定向

转载 作者:行者123 更新时间:2023-12-01 12:27:38 25 4
gpt4 key购买 nike

我想从这样的 url 进行重定向

/test/112321  to /test/
/test/test2/1311223 /test/test2/

url最后只有数字

现在我有

RewriteCond %{HTTP_HOST} ^(.*)([0-9]*)/$ [NC]
RewriteRule ^(.*)/([0-9]*)$ http://%1/$1/ [R=301,L]

但它不起作用。你能帮我解决这个问题吗?

最佳答案

你不需要RewriteCond %{HTTP_HOST}因为你正在匹配 REQUEST_URI你可以在 RewriteRule 中做本身。

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

RewriteEngine On

RewriteRule ^(.+)/([0-9]+)/?$ /$1/ [R=301,L,NE]

关于.htaccess - Htaccess 从末尾的数字重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37793473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com