简体   繁体   English

htaccess将文件夹重定向到新域索引

[英]htaccess redirect folder to new domain index only

I have looked and looked and cant find the answer, I would greatly appreciate your help!! 我已经看了看又找不到了答案,非常感谢您的帮助!

I designed a website in a folder on a dummy domain, and forgot to add "noindex" and now its indexed, I need to redirect all pages in that folder to the index of the new domain. 我在虚拟域上的文件夹中设计了一个网站,然后忘记添加“ noindex”,现在它已建立索引,我需要将该文件夹中的所有页面重定向到新域的索引。 example: http: //dummysite/clientsfolder/ (I had to put space here because I can't post 2 links) 示例:http:// dummysite / clientsfolder /(我必须在此处放置空格,因为我无法发布2个链接)

redirect to http://clientsnewdomain.com 重定向到http://clientsnewdomain.com

all the code I have found redirects to http ://clientsnewdomain.com/clients folder, whether I place it in the /clientsfolder or the http://dummysite/ and then this results in a 404 page. 无论我将其放在/ clientsfolder还是http:// dummysite /中 ,我找到的所有代码都重定向到http://clientsnewdomain.com/clients文件夹,然后生成404页面。 Got into a mess here. 在这里陷入混乱。

Also which is better to use to avoid this issue in the first place? 另外,首先使用哪个更好的方法来避免此问题? in or a robots.txt? 在还是robots.txt中?

Use that, in your /clientsfolder/.htaccess : /clientsfolder/.htaccess使用它:

RewriteEngine on 
RewriteRule ^(.*)$ http://clientsnewdomain.com/$1 [R=301,L]

OR in the root .htaccess : 或在根.htaccess

RewriteRule ^clientsfolder/(.*)$ http://clientsnewdomain.com/$1 [NC,R=301,L]

The best place to avoid this issue in the first place is to use robots.txt. 首先避免此问题的最佳方法是使用robots.txt。
But I prefer to use a folder protected by a password. 但是我更喜欢使用受密码保护的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM