I deployed recently an little website made with latest Laravel 4. All works well, url rewriting included.
But I noticed that Google indexed a few urls with the index.php
in the path. As you know, this can provoke a duplicate content problem.
I triple checked, and there's absolutely no way to access an url with index.php
when you browse the website. So I wonder how to prevent the framework to load the urls with index.php
, or at least a trick to redirect automatically to the correct url without the index.php
.
In the original htaccess, I only added this to force the www in url:
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/ [L,R=301]
I don't think it's the cause of this problem, but I mention it, just in case.
Thanks.
The route helper will automatically extract the model's route key: Laravel allows you to easily create "signed" URLs to named routes. These URLs have a "signature" hash appended to the query string which allows Laravel to verify that the URL has not been modified since it was created.
Laravel allows you to easily create "signed" URLs to named routes. These URLs have a "signature" hash appended to the query string which allows Laravel to verify that the URL has not been modified since it was created. Signed URLs are especially useful for routes that are publicly accessible yet need a layer of protection against URL manipulation.
In short, you might tell Google a specific route or page has "no restrictions for indexing or serving" by setting the X-Robots-Tag HTTP header to all or, on the contrary, tell it to stop indexing (or saving cached versions of a page) with the noindex value. In Laravel, the guys at Spatie made it really easy.
As mentioned by John Mueller, Webmaster Trends Analyst at Google, you can only use the Indexing API for Job posting & live stream structured pages. The package we use is called Laravel Google Indexing, a simple package that uses the Google PHP Client for making API requests.
This is what worked for me, helping me removine Laravel's index.php
from the url:
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
Google saves 404 pages, use Google Webmastertools to remove from their cache.
The Rule is wrong I think.
RewriteEngine on
RewriteRule ^/(.*)$ /index.php?$1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With