我想创建一个干净的 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 重定向
发布评论