Prerender.io subpages redirected to index

I followed the following guide:

In angular:

$locationProvider.html5Mode(true); 

In html add this meta header:

 <head> <meta name="fragment" content="!"> </head> 

Configure Apache:

  RewriteEngine On # If requested resource exists as a file or directory # (REQUEST_FILENAME is only relative in virtualhost context, so not usable) RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d # Go to it as is RewriteRule ^ - [L] # If non existent # If path ends with / and is not just a single /, redirect to without the trailing / RewriteCond %{REQUEST_URI} ^.*/$ RewriteCond %{REQUEST_URI} !^/$ RewriteRule ^(.*)/$ $1 [R,QSA,L] # Handle Prerender.io RequestHeader set X-Prerender-Token "YOUR_TOKEN" RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR] RewriteCond %{QUERY_STRING} _escaped_fragment_ # Proxy the request RewriteRule ^(.*)$ http://service.prerender.io/http://%{HTTP_HOST}$1 [P,L] # If non existent # Accept everything on index.html RewriteRule ^ /index.html 

Now my index site is finally picked up by Google.

HOWEVER, when I try to go to my sub site, it tells me that it is redirected to index.html

Can someone tell me what I'm doing wrong? I tried this for several weeks and could not find a solution :(

From google-bot-simulator :

enter image description here

+2
google-search apache .htaccess
source share
2 answers

You are testing your site with Googlebot, but this user agent is not on the list of possible user agents looking for Rewrite rules.

 RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR] 

The list above lists all the bots that will be proxied to prerender.io. More specifically, it lists only parts of the user agent that are sufficient to detect them. If you add googlebot then it will match that. Or maybe just a "bot" for testing purposes.

 RewriteCond %{HTTP_USER_AGENT} bot|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR] 

Give it a try. Also, see if your browser has a "User Agent Switcher" plugin that allows you to test faster than through Google tools.

+1
source share

What did your htaccess look like before? I think this will be the reason your subdomains will show index.html:

 # If non existent # Accept everything on index.html RewriteRule ^ /index.html 
0
source share

All Articles