Reputation: 729
I have a web site created with angularjs
. i want to redirect to a PHP
page when user is a GoogleBot
and for this i add some rules to htaccess
file.
but when i test from google bot this role does not execute.
my htaccess
is :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^my-site.com [NC]
RewriteRule ^(.*)$ http://www.my-site.com/$1 [L,R=301]
RewriteRule ^(panel|lists)($|/) - [L]
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (googlebot|InfoSeek|msnbot|Surp) [NC]
RewriteRule ^estate/([0-9]+)/?$ http://www.my-site.com/static-estate.php?id=$1 [NC,L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !ajax
RewriteRule ^(.*)$ /#!/$1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RedirectMatch 301 /%{REQUEST_FILENAME}/(.*) #!/%{REQUEST_FILENAME}/$1
i expect that this url
http://www.my-site.com/estate/123/text
redirect to :
http://www.my-site.com/static-estate.php?id=123
when user is GoogleBot
. but it redirects to
http://www.my-site.com/#!/estate/123/text
and by following url redirects to
http://www.my-site.com/
what is the problem here?
Upvotes: 1
Views: 392
Reputation: 10889
This line is wrong:
RewriteRule ^estate/([0-9]+)/?$ http://www.my-site.com/static-estate.php?id=$1 [NC,L,QSA]
because ^estate/([0-9]+)/?$
will not accept anything after /estate/123/
The exact correct line depends on if /text
is mandatory or optional, but something like this should do:
RewriteRule ^estate/([0-9]+)(/?|/[a-zA-Z0-9]*)/?$ http://www.example.com/static-estate.php?id=$1 [NC,L,QSA]
Upvotes: 1