htaccess的重定向到不同的文件夹中的同一个域中 [英] htaccess redirect to a different folder in same domain

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

问题描述

我有一个网站abc.com是我一直保持我的所有文件和文件夹。现在,我已经创建了一个名为newsite文件夹,然后将所有的文件到那里。现在我想,如果在浏览器中我的用户类型abc.com它会自动重定向到abc.com/newsite~~V

I have a website abc.com were i have kept all my files and folders. Now I have created a folder called "newsite" and moved all the files over to there. Now i want if my user type abc.com in browser it will automatically redirect them to abc.com/newsite

我使用的是Linux服务器与GoDaddy托管。我知道这可以通过htaccess文件来完成。任何人都可以帮助我在这?

I am using a linux server with godaddy hosting. I know this can be done through htaccess file. Can anyone help me on this?

我的htaccess的文件使用此但这不起作用

I am using this in htaccess file but this does not work

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.abc.com$
RewriteRule (.*)$ /newsite$1 [R,L]
</IfModule>

感谢你这么多提前

推荐答案

这应该做到这一点:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/newsite [NC]
RewriteRule ^ /newsite%{REQUEST_URI} [R=301,L]

的RewriteCond 检查,如果URL以 / newsite 开始,如果不将用户重定向到它。

The RewriteCond checks if the URL starts with /newsite if not it will redirect the user to it.

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

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