如何使用htaccess重定向特定页面

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

我一直在寻找htaccess代码来重定向单个页面,并且在很多解决方案上都没有运气。

I've looked all over for the htaccess code to redirect a single page and haven't had any luck with many solutions.

基本上,我需要重定向此页面:

Basically I need to redirect this:

/example/my-stuff/

至:

/example/home/

但我不希望重定向/ my-stuff /以外的其他页面。例如。这些页面不应重定向并保持不变。

but I don't want any other pages except for /my-stuff/ to be redirected. Eg. these pages should not be redirected and kept the same.

/example/my-stuff/a-page /example/my-stuff/anything

在此先感谢大家! :)

Thanks in advance guys! :)

推荐答案

在文档根目录的htaccess文件中,您可以添加以下任一内容:

In the htaccess file in your document root, you can add either this:

RedirectMatch 301 ^/example/my-stuff/$ /example/home/

或者您可以改用mod_rewrite:

Or you can use mod_rewrite instead:

RewriteEngine On RewriteRule ^example/my-stuff/$ /example/home/ [L,R=301]

更多推荐

如何使用htaccess重定向特定页面

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

发布评论

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

>www.elefans.com

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