atom feed2 messages in ru.sysoev.nginxRe: How to change Root URL
FromSent OnAttachments
Mohammed AshrafMar 28, 2011 12:18 pm 
Francis DalyMar 28, 2011 2:56 pm 
Subject:Re: How to change Root URL
From:Francis Daly (fran@daoine.org)
Date:Mar 28, 2011 2:56:43 pm
List:ru.sysoev.nginx

On Tue, Mar 29, 2011 at 12:48:56AM +0530, Mohammed Ashraf wrote:

Hi there,

I am new to nginx.

Welcome. There's lots of good information at http://nginx.org/ and http://wiki.nginx.org/ -- you can check there to understand what the suggested configuration will do.

How can I change my URL from lets say http://ip:80/sample/chap1/demo.jspto http://ip:80/*test/*sample/chap1/demo.jsp { pl note the path test between IP:port and sample)

I'd use a rewrite in the nginx config file, so when someone requests /url, they are invited to instead request /new/url; and when they request /new/url, they are given the content from the new directory.

Combining this example with the question in the Subject: line, I suggest:

location / { rewrite ^ /test$request_uri? permanent; }

location /test/ { }

See, for example, http://wiki.nginx.org/HttpRewriteModule#rewrite for what the rewrite directive does; and http://wiki.nginx.org/HttpCoreModule#location for how the location blocks are matched.

Depending on what else you want the server to do, you will want more location blocks; and you may want to add "^~" to one of the above locations.

Good luck with it,

f