Report this

What is the reason for this report?

Redirect index.php to / only in main folder

Posted on March 15, 2016

Hello,

I am using LEMP droplet. For SEO purposes, I made redirection from site.com/index.php to site.com like this:

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

It works just fine, but I need it to work on root folder of the site only. It currently redirects all folders, in example /folder/index.php will be redirected to /folder/

This prevents some of my scripts to work normally (Joomla backend in example). How can I change the above code and make this redirection for root folder only.

Thanks, Milos

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.