开发者

Is it possible to (virtually) move a site from www.example.org/ to www.example.org/new/ with htaccess?

I'm wondering if it is possible to upload a site to the root directory, but not make it already visible for public (and Google for SEO reasons). And what is the be开发者_如何学JAVAst way for that?

Is it possible with some rules in the .htaccess file to let it look like the site is www.example.org/new/ instead of www.example.org?

Thanks


To redirect all links to www.example.org to goto www.example.org/new add this to your .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{REQUEST_URI} ^/new/
  RewriteRule ^(.*) $1 [L]

  RewriteRule ^(.*)$ /new/$1 [L,R=301]
</IfModule>

I'm a bit confused by your question. You subject line seems to ask a different question to the body of the question. But if you don't want search engines to crawl your new site while you working on it add it to robots.txt (though if there is no link on your old site to the new one it should not crawl the new site anyway). And you might want to password protect it as well.

Also for SEO purposes you will not want to break links on the old site once you go live with new site. Use rewrite rules like so:

RewriteRule ^corporateplan$ /corporate-services/corporate-plan [L,R=301]


I would create a virtualhost under example.org like beta.example.org and password-protect it until the new site will launch. If everything looks fine, i would update my Apache.conf to point the new dir as DocumentRoot.


I prefer to test stuff with the definitive directory structure. That way I'm sure that nothing will break when I go live due to errors in relative or absolute paths.

If it's a brand new site, I just password protect it with Apache mod_auth_* modules. If it's a new version of an existing site, I create a new site under a subdomain.

Update

In a shared hosting environment your options are pretty limited. You have to physically upload the site in the new folder or otherwise it'll overwrite the old site. In such case, nothing special would be needed.


You may disallow robots with robots.txt. I don't know will it help you but I am using that way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜