重定向所有页面顶级页面 [英] Redirect all pages to top level page

查看:120
本文介绍了重定向所有页面顶级页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何重定向一个URL的所有页面,以最顶级的网页?

How can I redirect all pages on a single URL to the most top level page?

例如,如果有人试图进入 http://www.thisdomain.com/sample-子页面他们将被重定向到 http://www.thisdomain.com

For example, if someone tries to enter http://www.thisdomain.com/sample-sub-page they'll be redirected to http://www.thisdomain.com

在讨论的领域有许多关于它的Word preSS装置,所以我宁愿没有单独编辑WP的每个实例。我想有一个小htaccess的片段我可以使用?

The domain in question has a number of Wordpress installations on it so I'd rather not have to edit each instance of WP individually. I assume there's a little htaccess snippet I can use?

我需要能够重定向的所有请求都那些链接到实际页面和那些在错误输入

I need to be able to redirect ALL requests both ones that link to actual pages and those that are entered in error.

推荐答案

的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在< $ C C>的.htaccess $ DOCUMENT_ROOT 目录下:

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^sample-sub-page/?$ / [L,R=301,NC]

这篇关于重定向所有页面顶级页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆