大众301重定向使用的.htaccess

编程入门 行业动态 更新时间:2024-10-14 08:23:49
本文介绍了大众301重定向使用的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的工作,涉及以数千(30,000)静态网页,使之成为一个CMS一个大项目。

I am working on a large project that involves taking thousands (30,000+) static web pages and turning it into to a CMS.

问题是许多这些网页都是他们的目录中出现重复。我希望通过使用301重定向,以保持完整的搜索引擎优化,但是,我不知道如何去这样做这么大的重定向(301)。

The issue is many of these pages are duplicates within their directories. I want to keep the SEO intact by using 301 redirects, however, I am not sure how to go about doing such a large redirect (301).

下面是对页面具有当前目录结构的一个例子。

Here is an example of the current directory structure for the pages.

/page.html /folder/page.html /folder/subfolder/page.html /folder/subfolder/anotherfolder/page.html

正如你所看到的 page.html即可的是重复的所有目录。

As you can see page.html is duplicated in all the directories.

有关新型农村合作医疗的URL,该网页将只是 /page.html 。

For the new CMS the URL to that page would just be /page.html.

推荐答案

您应该直接重定向到/page.html

Working example, visit: www.jakeisonline/stackoverflow/3345518-mass-301-redirect/page.html

You should be redirected straight to /page.html

Options +FollowSymlinks RewriteEngine on RewriteRule ^(.*)page.html /page.html [R=301,NC]

这将始终重定向www.foo/something/something/something/page.html回到 www.foo/page.html 使用301重定向硬

This will always redirect www.foo/something/something/something/page.html back to www.foo/page.html using a 301 hard redirect.

重写规则做到这一点通过查看URL,如果page.html即可之前任何包含(不含域本身)确定,如果是,则在301重定向。所以,你可以从字面上使用任何分层次,只要它与page.html即可结束,它会重定向在根目录下/page.html。

The rewrite rule does this by looking at the URL, determining if anything before page.html is included (excluding the domain itself) and if it is, will 301 redirect. So you can literally use any sub-level, and as long as it ends with page.html, it will redirect to /page.html in the root directory.

如果你想知道什么 [R = 301,NC] 表示,

In case you're wondering what [R=301,NC] means,

R // means simple redirect R=301 // means redirect with a 301 header NC // means no-case, or case insensitive L // can also be used to say 'ignore all the other rules after this'

更多推荐

大众301重定向使用的.htaccess

本文发布于:2023-10-31 13:44:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546261.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大众   重定向   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!