Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to set a initial page inside a folder, besides the common index.htm

I want to change index.htm to /folder/file.htm

Is it possible using nginx?

In my Apache server all I have to do is config the htaccess file, putting this: DirectoryIndex /folder/file.htm

PS: I tried to do that with RegEx, but I really preffer with DirectoryIndex

Thanks a lot in advance!!!

share|improve this question
    
The equivalent directive for nginx is index. You can specify multiple files, and/or an absolute path that will result in an internal redirect. –  cyberx86 Jun 28 '12 at 5:24
    
@cyberx86 Why not post that as an answer? –  mgorven Jun 28 '12 at 5:54

1 Answer 1

Nginx has a directive, index, that is equivalent to Apache's DirectoryIndex. As per the documentation:

index
Syntax: index file ...
Default: index.html
Context: http, server, location

Sets the default file to serve if a directory is requested by the client. Multiple files can be specified. If the first file isn't found, the second will be used and so on. If the last entry begins with a /, and none of the earlier files are found, nginx will perform an internal redirect to this uri.

e.g. index index.html index.php /index.php;

As indicated from the above, you can specify multiple files, each of which will be tried in sequence, and can also specify an full path if the file you wish to use is not under the current directory.

share|improve this answer
    
Thanks a lot cyberx86, I will try this and let you know if worked. –  Gus Jun 28 '12 at 12:52
    
I have a special php file that lists directories and wanted all directories without their own index files to be rewritten to that file - using an absolute path with this directive as the last parameter did just that. Works fine, thanks! –  Strayer Dec 10 '12 at 11:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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