如何重定向 - 将网址重写为短网址
我改变了我的网站网址结构。但是,Google 索引的网址给出了 404 未找到错误。现在,我需要一个 .htaccess 重写规则,
来自 url: www.mydomain.com/topic-titles-here-t273.html
到 url: www.mydomain。 com/sub-folder/topic273.html
(必须缓存主题 ID,并且必须删除主题标题。)
有时,也像这样,
来自 url: www.mydomain.com/topic-titles- here-t273-15.html
到网址: www.mydomain.com/sub-folder/topic273-15.html
我搜索了很多,大约三个小时,但找不到正确的答案。请帮忙。
I have changed my site url structure. But, Google indexed urls are giving 404 not found error. Now, I need a .htaccess rewrite rule for,
From url: www.mydomain.com/topic-titles-here-t273.html
To url: www.mydomain.com/sub-folder/topic273.html
(Topic id must be cached and topic title must be removed.)
Some times, like this also,
From url: www.mydomain.com/topic-titles-here-t273-15.html
To url: www.mydomain.com/sub-folder/topic273-15.html
I searched a lot, for about three hours, But couldn't find correct answer. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有点不清楚你想要做什么,但
1
将采取第二组(仅 273.html)并相应附加,第一组将是
之前的所有内容(主题-标题-此处-t)
都是您所需要的吗?如果是这样,正则表达式可以整理一下,我只是想演示两组
更新 - 好的,根据编辑,第二组就变成了,
如果本示例中使用的 273 可以长于 3 个数字,如果您知道确切的数字,则只需修改该数字,否则使用 +
I am a little unclear on what you are trying to do but
1
Would take the second group (just 273.html) and append accordingly, the first group would be
everything before (topic-titles-here-t)
is that what you require? If so the regex could be tidied I just wanted to demonstrate the two groups
update - Ok according to edit the second group just becomes
if 273 used in this example can be longer than 3 nubers if you know exact just amend that number otherwise use +