Nginx 403 after files have been moved from other provider

August 17, 2014 910 views

Greetings to all,

First I would like to thank DigitalOcean for their excellent tutorials and How-To's and to all kind members supplying really excellent stuff.
Information found here is a true gem!

Now I have a problem with webserver nginx and I don't know how to solve if directories does not contain index.php. I get 403 error!

For example lets say I have folder structure as follows:

/contact/ (folder)

  • contact.php

/about/ (folder)

  • about.php

Do I have to rename the files to index.php or can it be solved in any other way?

Cheers to all in the ocean!

  • Since I used apache on the other host I have made some rewrite rules -

    RewriteRule ^contact/$ /contact/contact.php

    Is this causing the problem? If yes how do I make the rewrite rule to apply to nginx?

  • Ok I think I managed to solve it by adding rewrite rules -

    location = /contact/ {
            rewrite ^(.*)$ /contact/contact.php;
1 Answer

By default, if you go to a directory's url, only the index file be shown. This is configured by this setting in your Nginx configuration,

index index.php index.html index.htm;

That said, your solution is generally how it is handled for a non-standard directory:

location = /contact/ {
        rewrite ^(.*)$ /contact/contact.php;

Thanks for following up and sharing your solution!

Have another answer? Share your knowledge.