将子文件夹重定向到根域 [英] Redirect subfolder to root domain

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

问题描述

我想将子文件夹和所有内容重定向到根域.

I want to redirect the subfolder and allcontents to root domain.

例如:

http://www.example.com/ubb/将重定向到 http://www.example.com

我将.htaccess放在ubb文件夹中,代码为:

I put the .htaccess on ubb folder and the code is:

RewriteEngine On
RewriteRule ^.*$ / [R=302,L]

但是,当您访问 http://www.example.com/ubb/threads.php 它将重定向到 http://www.example.com/threads.php 应该是 http://www.example.com

However when you access http://www.example.com/ubb/threads.php it will redirect to http://www.example.com/threads.php it should be http://www.example.com

有没有可以尝试的代码或其他可能的解决方案?

Is there any code to try or other possible solution?

推荐答案

将此规则放在/ubb/.htaccess中:

RewriteEngine On
RewriteBase /ubb/

RewriteRule ^ /? [R=302,L]

还要在其他浏览器中进行测试,以避免现有的浏览器缓存.

Also test it out in a different browser to avoid existing browser caches.

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

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