index.php作为laravel网站url中的参数(index.php as a parameter in the url of laravel website)

我发现可以使用index.php作为参数访问任何laravel网站。

这是一个大问题,url参数中的index.php会破坏所有图像。 看一个真实的例子来理解我的意思:

http://www.cyprusalive.com/main-thing/sightseeing http://www.cyprusalive.com/index.php/main-thing/sightseeing

Googlebot使用index.php作为url参数读取一些网址。 当有人通过google搜索使用index.php访问网站时,这会影响所有图像。

此外,这是一个糟糕的seo练习,因为产生重复的内容。

解决这个问题的最佳方法是什么?

I discovered that any laravel website is accessible with index.php as a parameter.

This is a big problem, index.php in url parameter breaks all images. Look at a real example to understand what I mean:

http://www.cyprusalive.com/main-thing/sightseeing http://www.cyprusalive.com/index.php/main-thing/sightseeing

Googlebot read some urls with index.php as a parameter of url. This has effect to breaks all images when someone get access to the website from google search with index.php.

Also, this is a bad seo practice because produce duplicate content.

What is the best way to fix that?

最满意答案

可以使用nginx重写规则修复此问题。 使用波纹管规则将带有index.php参数的所有URL重定向到original laravel route url

location /index.php { rewrite ^/index.php(.*)$ http://$server_name$1; }

另外,我把以下内容放到robots.txt

Disallow: /*index.php*

The problem could be fixed with nginx rewrite rules. Using the bellow rule redirect all urls with index.php parameter to the original laravel route url

location /index.php { rewrite ^/index.php(.*)$ http://$server_name$1; }

Also I've put the follow to the robots.txt

Disallow: /*index.php*

更多推荐