重定向所有页面顶级页面

编程入门 行业动态 更新时间:2024-10-26 12:30:11
本文介绍了重定向所有页面顶级页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

在讨论的领域有许多关于它的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在的.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]

更多推荐

重定向所有页面顶级页面

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

发布评论

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

>www.elefans.com

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