gpt4 book ai didi

url-rewriting - 如何重定向 - 将 url 重写为短 url

转载 作者:bug小助手 更新时间:2023-10-28 01:29:40 26 4
gpt4 key购买 nike

我更改了我的网站网址结构。但是,谷歌索引的 url 给出了 404 not found 错误。现在,我需要一个 .htaccess 重写规则,

来自网址: www.mydomain.com/topic-titles-here-t273.html

到网址: www.mydomain.com/sub-folder/topic273.html

(必须缓存主题ID,必须删除主题标题。)

有时候,也是这样,

来自网址: www.mydomain.com/topic-titles-here-t273-15.html

到网址: www.mydomain.com/sub-folder/topic273-15.html

我搜索了很多,大约三个小时,但找不到正确的答案。请帮忙。

最佳答案

我有点不清楚你想做什么,但是

1

RewriteRule    ^([a-z|-]+)(\d+\.html)$    /sub-folder/topic$2    [NC,L]  

将采用第二组(仅 273.html)并相应地附加,第一组将是之前的所有内容(topic-titles-here-t)

这是你需要的吗?如果是这样,可以整理正则表达式我只是想展示这两个组

更新 - 好的,根据编辑第二组就变成了

(\d{3}-\d+\.html)

如果此示例中使用的 273 可以超过 3 个 nubers,如果您知道准确,则只需修改该数字,否则使用 +

关于url-rewriting - 如何重定向 - 将 url 重写为短 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5056249/

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