htaccess的重定向 [英] .htaccess redirect

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

问题描述

我想创建一个干净的URL,如,让说,我有一个网站www.mywebsite.com,我想,如果有人尝试的 http://www.mywebsite.com/something ,他应该被重定向到www.mywebsite.com,

让键入提前mywebsite.com/,他们应该得到重定向到www.mywebsite.com

任何事情

我怎么能做到这一点在.htaccess,好心帮。

解决方案

  RewriteEngine叙述ON
重写规则^ / + / [L,R]
 

这将重定向一切/作为一个永久重定向。看看 http://httpd.apache.org/docs/2.0/mod/mod_rewrite .HTML 上你可以添加透明度等等等等的标志的详细信息。

如果你想这样的的.htaccess 请确保您有正确的覆盖指示在<虚拟主机> 配置。

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

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

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

解决方案

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

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

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

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

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