1

Actually, there is no index.php in urls of our website but the home page only. So to solve the "Multiple URLs found for index page" seo issue, with below changes in nginx configuration I could remove it from "landing page". But now I have problem to access admin panel.

if ($request_uri ~ .*.index\.php(.*)) {
return 301 http://test.example.com;  
}
1

You could exclude the admin url:

if ($request_uri ~ .*.index\.php(.*)) {
    if ($request_uri ~ .*.index\.php\/admin(.*)){
       //do nothing
     } else {
       return 301 http://test.example.com;  
    }
}

I'm not sure about inverse matching to do it in one if statement, but you can try something like https://stackoverflow.com/questions/406230/regular-expression-to-match-line-that-doesnt-contain-a-word

  • I'm getting this error now, nginx: [emerg] "if" directive is not allowed here in... I placed it inside server {} block – Zinat May 23 '16 at 5:35
  • The error is in if ($request_uri ~ .*.index\.php\/admin(.*)) statement – Zinat May 23 '16 at 5:43
1

Below solved the issue of landing page url (Source) . Cheers :)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.