mic*_*ano 5 apache .htaccess seo redirect http-status-code-301
我正在开展一个大型项目,涉及获取数千(30,000+)个静态网页并将其转换为CMS.
问题是这些页面中的许多页面在其目录中是重复的.我想通过使用301重定向保持SEO完好无损,但是,我不知道如何进行如此大的重定向(301).
以下是页面当前目录结构的示例.
/page.html /folder/page.html /folder/subfolder/page.html /folder/subfolder/anotherfolder/page.html
如您所见,page.html在所有目录中都是重复的.
对于新CMS,该页面的URL就是/page.html.
您应该直接重定向到/page.html
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)page.html /page.html [R=301,NC]
Run Code Online (Sandbox Code Playgroud)
这将始终使用301硬重定向将http://www.foo.com/something/something/something/page.html重定向回http://www.foo.com/page.html.
重写规则通过查看URL来确定是否包含page.html之前的任何内容(不包括域本身),如果是,则301将重定向.所以你可以逐字地使用任何子级别,只要它以page.html结尾,它就会重定向到根目录中的/page.html.
如果你想知道是什么[R=301,NC]意思,
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'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2033 次 |
| 最近记录: |