How do i tell google to not crawl a domain completly - seo

I have a site in opencart say abc.com and i have opened a multi store with it xyz.com and i have found that google has started crawling xyz.com too which i don't want .
Both the domains are pointing to the same directory so i suppose there can only be one robots.txt file . I am not very experienced with google webmaster or SEO so please tell me how can i tell google to ignore all the urls starting with xyz.com .

If you are using Apache and mod_rewrite you can add a rewrite rule to serve a different robots.txt file for xyz.com:
RewriteCond %{HTTP_HOST} xyz.com$ [NC]
RewriteRule ^robots.txt robots_xyz.txt [L]
Then create robots_xyz.txt:
User-agent: *
Disallow: /

Related

Domain masking across different servers with Htaccess

I have a Wordpress install on domain1.com/blog but ideally I would like it to display as sub.domain2.com/blog.
These domains are on separate servers. Ideally I would install WP on same server as domain2 but this isn't possible right now.
I've been able to get sub.domain2.com/blog to display the WP homepage but is it possible for htaccess and apache to rewrite the urls on domain1.com to display as sub.domain2.com?
Other than simple url rewrites I have limited experience with htaccess but I suspect for security reasons this isn't possible.
You can of course, redirect your requests on domain1.com to sub.domain2.com:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(blog/.*)$ http://sub.domain2.com/$1 [R=301,L]
Put the above in a htaccess file for the domain1.com.

How to redirect to subdomain but then allow normal use of site

So I have my site, www.domain.com.
For a week or so I want to direct all traffic going direct to the site to subdomain.domain.com, a little promo page about an upcoming feature. I want visitors to then be able to continue to the site as normal though after they've read it, so a continue to www.domain.com/index.php link.
How can I do that with in the htaccess file? Everything I've tried so far messes up when clicking the continue link.
Thanks
with .htaccess you could use a 302 temporary redirect, but it would be for a whole sub folder as far as I know.
Another way would be to redirect with JS/server site language to the subdomain, create a cookie, then redirect back to www.domain.com/index.php .
the 302 redirect is explained here: How do I redirect my site using a .htaccess file?
You would need to have a .htaccess for the root folder point to your subdomain
Note that this is only possible if you enable mod_proxy in the Apache config of domain.com otherwise URL will change after redirect.
Enable mod_proxy, mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^index\.php$ http://subdomain.domain.com/ [L,NC,P]

Robots.txt for multiple domains

We have different domains for each language
www.abc.com
www.abc.se
www.abc.de
And then we have different sitemap.xml for each site. In robots.txt, I want to add sitemap reference for each domain.
Is it possible to have multiple sitemap references for each domain in single robots.txt?
If there are multiple, which one does it pick?
I'm using the following solution in .htaccess after all domain redirects and www to non-www redirection.
# Rewrite URL for robots.txt
RewriteRule ^robots\.txt$ robots/%{HTTP_HOST}.txt [L]
Create a new directory in your root called robots.
Create a text file filled with the specific robots information for every domain.
/robots/abc.com.txt
/robots/abc.se.txt
/robots/abc.de.txt
The robots.txt can only inform the search engines of sitemaps for its own domain. So that one will be the only one it honors when it crawls that domain's robots.txt. If all three domains map to the same website and share a robots.txt then the search engines will effectively find each sitemap.
Based on Hans2103's answer, I wrote this one that should be safe to be included in just about every web project:
# URL Rewrite solution for robots.txt for multidomains on single docroot
RewriteCond %{REQUEST_FILENAME} !-d # not an existing dir
RewriteCond %{REQUEST_FILENAME} !-f # not an existing file
RewriteCond robots/%{HTTP_HOST}.txt -f # and the specific robots file exists
RewriteRule ^robots\.txt$ robots/%{HTTP_HOST}.txt [L]
This rewrite condition should just serve the normal robots.txt if it's present and only look for a robots/ directory with the specified file robots/<domain.tld>.txt.

.htaccess - Redirect for all users, except me

Please help me with the htaccess. I tried to create a rule whereby a user visiting a particular web page is automatically redirected to another page on the site, but if I visit it page, this rule does not work for me (for a specific IP address).
LiteSpeed ​​installed on the server, and I think fits the rule for Apache (correct if I'm wrong, I just do not understand the server software).
Sorry for bad english.
This is a 302-Moved Temporarily redirection.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^xxx\.xxx\.xxx\.xxx
RewriteRule \.html$ /anotherPage.html [R=302,L]
where xxx.xxx.xxx.xxx is your ip and anotherPage.html is the redirection page.

How can I redirect links to an old home.asp file to a new index.php?

I am working on a website that has a lot of old, incoming links on external sites. These links point to http://domain.com/home.asp .
However, the current site is built in WordPress, with http://domain.com/ as the URL with index.php being in the root.
Currently, any links pointing to the home.asp are redirecting to a 404 Not Found. What is the best way to redirect those links to the new index.php? Is .htaccess my best bet?
Thank you for reading.
In .htaccess:
RewriteEngine On
RewriteRule ^/home.asp / [L,R=301]
should do the trick
L means stop rewriting after this line
R=301 means to send an MOVED PERMANENTLY respons to the client