htaccess的重定向 [英] .htaccess redirect
问题描述
我想创建一个干净的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屋!