Urls indexed on Google using index.php, Laravel is configured not to use it in paths

I recently hosted a small website with the latest Laravel 4. Everything works well, including correspondence.

But I noticed that Google indexed several URLs with index.php in the path. As you know, this can cause a problem with duplicate content.

I checked three times and there is absolutely no way to access the URL from index.php while browsing the website. So I'm wondering how to prevent the URL loading framework using index.php or at least the trick to automatically redirect to the correct URL without index.php .

In the original htaccess, I just added this to force www in the url:

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

I do not think this is the cause of this problem, but I mention it just in case.

Thanks.

+6
source share
4 answers

This is what worked for me, helping me remove Laravel index.php from the URL:

 RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] 
+4
source

Google saves 404 pages, uses Google Webmastertools to remove from its cache.

The rule is wrong, I think.

 RewriteEngine on RewriteRule ^/(.*)$ /index.php?$1 
+2
source

Check the url configuration parameter in /app/config/app.php The default is localhost . Make sure your .htaccess file is in the shared folder and your server (e.g. apache) points to the shared folder of your application. Do composer dump-autoload --optimize and php artisan optimize

0
source

You can use this .htaccess syntax:

 RewriteRule ^index.php/(.*)$ /$1 [L,R=301] 
0
source

Source: https://habr.com/ru/post/947779/


All Articles