本文介绍了如何使用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重定向特定页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!