Mobile app version of vmapp.org
Login or Join
Gail5422790

: "Syntax not understood" error in Google Webmaster Tools robots.txt analysis when I use RewriteRule In order to redirect my www.site.com to non-www, I employed this bit of code found somewhere

@Gail5422790

Posted in: #GoogleSearchConsole #RobotsTxt #UrlRewriting

In order to redirect my site.com to non-www, I employed this bit of code found somewhere on the web.

RewriteCond %{HTTP_HOST} ^www.website.com [NC]
RewriteRule ^(.*)$ website.com/ [L,R=301]


Although the site redirects fine, I get the "syntax not understood" warning in Google Webmaster Tools under:

webmaster tools-> Crawl-> Blocked URLs->robots.txt analysis

Google Webmaster Tools detects the sitemap just fine. I guess not much is wrong because of this, but is there a way to correct this, as I am getting errors like below:

Line 20: RewriteCond %{HTTP_HOST} ^www.website.com [NC] Syntax not understood
Line 21: RewriteRule ^(.*)$ website.com/ [L,R=301] Syntax not understood




This is how it displays when I visit the robots.txt directly.

User-agent: *

Disallow: /cgi-bin/
Disallow: /jwp/
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/plugins/
Disallow: /wp-content/cache/
Disallow: /wp-content/themes/
Disallow: /trackback/
Disallow: /feed/
Disallow: /comments/
Disallow: /category/*/*
Disallow: */trackback/
Disallow: */feed/
Disallow: */comments/
Disallow: /*?

# REDIRECTING TO NON-WWW
RewriteCond %{HTTP_HOST} ^www.website.com [NC]
RewriteRule ^(.*)$ website.com/ [L,R=301]

Sitemap: website.com/sitemap_index.xml

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

1 Comments

Sorted by latest first Latest Oldest Best

 

@Mendez628

this belongs in .htaccess not robots.txt

# REDIRECTING TO NON-WWW
RewriteCond %{HTTP_HOST} ^www.website.com [NC]
RewriteRule ^(.*)$ website.com/ [L,R=301]


and "website" needs to be your website not website.com.

If when you type yourwebsite.com it redirects to yourwebsite.com then .htaccess is fine. Just take it out of robots.txt. If the site is not redirecting check your cpanel first to see if the redirect control exists there.

This line should be removed.

Disallow: /*?


unless you want to block the entire site!.

Are you sure you want to block category pages?

Disallow: /category/*/*


If not remove that line.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme