nystudio107 / nginx-craft

An Nginx virtual host configuration for Craft CMS that implements a number of best-practices.
MIT License
310 stars 37 forks source link

URLs that ends with .index.php doesn't redirect to ones without it #7

Closed KhaledGabr closed 7 years ago

KhaledGabr commented 7 years ago

Google has indexed 2 versions of my login page because both /login and /index.php/login returns the same page.

The same issue occurs here to: https://nystudio107.com/index.php/blog https://nystudio107.com/blog

Can you please help fixing that. Thanks in advance.

khalwat commented 7 years ago

If you really wanted to, you could set up some kind of redirect to fix this, but the easiest thing to do is just use <meta name="canonical" content="https://yoursite.com/blog"> to indicate the canonical URL.

lboaretto commented 6 years ago

A solution for this:

if ($request_uri ~* "^(.*/)index\.php$") {
    return 301 $1;
}

rewrite ^(.*/)index$ $1 permanent;
rewrite ^(.*/)index.htm$ $1 permanent;
rewrite ^(.*/)index.html$ $1 permanent;

rewrite ^/(.*)/$ /$1 permanent;
merge_slashes off;
rewrite (.*)//+(.*) $1/$2 permanent;