找到你要的答案

Q:I want to redirect root and sub folders to different pages

Q:我想将根目录和子文件夹重定向到不同的页面

I want to redirect a root domain to another domain. The problem is, I also want to keep the subfolders.

For example: redirect domain/subfolder to anotherdomain/subfolder.

我想将根域重定向到另一个域。问题是,我还想让子文件夹。

例如:重定向文件夹的子文件夹anotherdomain /域/。

answer1: 回答1:

Because your question is not specific, I can only assume you need the following:

RewriteEngine On

# Check if a directory is being requested
RewriteCond %{REQUEST_FILENAME} -d

# If so, redirect the request
RewriteRule ^(.*)$ http://anotherdomain.com/$1 [R,L]

Update - Try this, based on the requirement in your comment.

RewriteRule ^$ http://www.kaysellers.com/webpage/ [R,L]
RewriteRule ^(.*)$ http://www.kaysellers.com/$1 [R,L]

You may change the R flag to R=301 to make it permanent, if you would like it to be.


Note: Please try and do your own homework in future. You should ask questions on StackOverflow when you have, at the very least, made an attempt to do what you want to do and not had any luck.

因为你的问题不具体,我只能假设你需要以下:

RewriteEngine On

# Check if a directory is being requested
RewriteCond %{REQUEST_FILENAME} -d

# If so, redirect the request
RewriteRule ^(.*)$ http://anotherdomain.com/$1 [R,L]

更新-尝试此,根据您的评论的要求。

RewriteRule ^$ http://www.kaysellers.com/webpage/ [R,L]
RewriteRule ^(.*)$ http://www.kaysellers.com/$1 [R,L]

你可以改变R标志,以R = 301,使其永久,如果你想它是。


注:请尝试做自己的功课在未来。你应该问的问题,当你在StackOverflow,至少尝试去做你想做的,没有任何运气。

.htaccess