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.

Let's say i have a virtual host in Nginx wtih name www.domain.com and root directory named public. Inside public i have 2 dirs dir1 and dir2. How i redirect the request to www.domain.com to dir1? I know it's a simple question, but i am new to nginx.

share|improve this question

1 Answer 1

Do you want to redirect visitors from www.domain.com to www.domain.com/dir1 ?

Then you can use a rewrite statement to rewrite. When you include http:// or https:// in the rewrite it will redirect visitors.

rewrite http://www.domain.com/(.*) http://www.domain.com/$1;

If you just want to use dir1 to serve content from, you can use alias, or you can rewrite without http:// like this:

rewrite / /dir1/;
share|improve this answer

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.