.htaccess 重定向

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

我想创建一个干净的 url,例如,我有一个网站 www.mywebsite,我想要,如果有人尝试 www.mywebsite/something,他应该被重定向到 www.mywebsite,

i want to create a clean url, as in, let say, i have a site www.mywebsite, i want, if anybody tries www.mywebsite/something, he should get redirected to www.mywebsite,

所以任何在 mywebsite/之前输入的内容都应该被重定向到 www.mywebsite

so any thing that is typed ahead of mywebsite/ they should get redirected to www.mywebsite

我如何在 .htaccess 中执行此操作,请帮忙.

how can i do this in .htaccess, kindly help.

推荐答案

RewriteEngine ON RewriteRule ^/.+ / [L,R]

这会将所有内容重定向到/作为永久重定向.看看 httpd.apache/docs/2.0/mod/mod_rewrite.html 有关您可以为透明度等添加的标志的更多信息.

That will redirect everything to / as a permanent redirect. Look at httpd.apache/docs/2.0/mod/mod_rewrite.html for more information on the flags you can add for transparency etc etc.

如果您想在 .htaccess 中使用它,请确保您的 <VirtualHost > 配置中有正确的覆盖指令.

If you want this in .htaccess make sure you have the correct override directives in your <VirtualHost > config.

更多推荐

.htaccess 重定向

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

发布评论

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

>www.elefans.com

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