301 从子文件夹中的动态 URL 重定向到新的静态 URL
我查看了将动态 URL 重定向到静态 URL 的所有不同解决方案,但找不到与我的问题相关的任何案例。
我想知道 .htaccess 的正确 301 重定向规则应该是什么
附加信息:
- 启动新网站后旧 URL 已被删除。
- 旧 URL 位于子文件夹 (/desarrollo/mantenedores/) 中,
- “art_id”是字符串,“61”是文章
下面是我想要将旧动态 URL 重定向到其各自的静态 URL 的情况。
旧网址 = http://example.com/desarrollo/mantenedores/art_indice.asp? art_id=61
新网址 = http://example.com/comunidad/articles/2/tipos-de-sociedades
谢谢...
I reviewed all the different solutions for redirecting dynamic URLs to a static URL but I couldn't find any case related with my question.
I would like to know what should be the correct 301 redirect rule for .htaccess
Additional info:
- The old URLs were deleted after launching the new site.
- The Old URLs are located in a subfolder (/desarrollo/mantenedores/)
- "art_id" is the string and the "61" is the article
Here is the case I want to redirect OLD Dynamic URLs to their individual static URLs.
Old URL = http://example.com/desarrollo/mantenedores/art_indice.asp?art_id=61
New URL = http://example.com/comunidad/articles/2/tipos-de-sociedades
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试填写重写映射文件(请参见此处)与 URL 目标的对应关系。
创建一个映射文件,在其中放置所需的所有类别:
关于您的示例,您的映射文件可能会填充以下内容:
然后这里是最困难的部分:
这应该可行。
如果它不尝试将 first RewriteRule 指令中的
%1
更改为%2
。如果仍然没有,您可能有足够的线索来完成任务。
如果您没有足够的线索...
两个提示:
请尝试使用
RewriteLog
指令:它可以帮助您追踪此类问题:我最喜欢的检查正则表达式的工具:
http://www.quanetic.com/Regex (不要忘记选择 ereg(POSIX) 而不是 preg(PCRE )!)
Please try to fill a rewritemap file (see here) to make a correspondance with the URL destination.
Create a mapfile where you put all the categories you need:
Regarding your sample, your map file may be filled with things like:
Then here you go for the hard part:
This should work.
If it doesn't try to change
%1
to%2
in the first RewriteRule directive.If it still doesn't you may have enough clues to finish the job.
If you don't have enough clues...
Two hints:
Please try to use the
RewriteLog
directive: it helps you to track down such problems:My favorite tool to check for regexp:
http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)