-2

I'd like visitors to continue see a domain (www.example.com) but searchengines have to redirect to the new site (www.newsite.com).

I need this redirect only for the homepage. I know I can achieve this with a rel canonical but if I'd want to insert something in htaccess how can I do this?

In this link i see something similar (the opposite of what i need), but I dont'know how to ajust it so it suits my needs.

this is my htaccess (where i can put the code lines?)

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName example.it

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

# END WordPress    
Community
  • 1
  • 1
luigi
  • 23
  • 3

2 Answers2

1

From the answer in the purposed helpful link, remove the exclamation marks !:

RewriteEngine On 

RewriteCond %{REMOTE_ADDR} ^(110\.174\.129\.147|203\.217\.17\.162)
RewriteCond %{HTTP_USER_AGENT} (Googlebot|msnbot|Surp) [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NE]

So in your .htaccess example, change this:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

To this:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REMOTE_ADDR} ^(110\.174\.129\.147|203\.217\.17\.162)
RewriteCond %{HTTP_USER_AGENT} (Googlebot|msnbot|Surp) [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NE]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
RichardBernards
  • 3,146
  • 1
  • 22
  • 30
  • thank you @RichardBernards ....this is my htacces....(where have i insert the lines above?) IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* order deny,allow deny from all allow from all order deny,allow deny from all AuthName example.it # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress – luigi Dec 02 '14 at 10:46
  • thanks for your help ...i did the change....but in google webmastertolls when i go to scan > see how Google... it show sme the old domain no a redirect status... – luigi Dec 02 '14 at 11:54
  • have i to change the code numer 110\.174 etc etc with other number?...i don't know what these number mean – luigi Dec 02 '14 at 12:05
  • @luigi I don't know exactly how webmastertools scans your page, so sadly no help there. The numbers are parts of ip-addresses which are used by searchengines to crawl. It could be the webmastertools use a different ip for scanning your page than the actual Googlebot does... – RichardBernards Dec 02 '14 at 12:15
1

ok thanks to @RichardBernards.....it works great...i deleted the line code

RewriteCond %{REMOTE_ADDR} ^(110\.174\.129\.147|203\.217\.17\.162)

and now it is ok.....thank you very much

luigi
  • 23
  • 3