Question

Nginx 403 after files have been moved from other provider

  • Posted August 17, 2014

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!

Subscribe
Share

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

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

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?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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!