我更改了我的网站网址结构。但是,谷歌索引的 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,如果您知道准确,则只需修改该数字,否则使用 +
我是一名优秀的程序员,十分优秀!