How to change Root URL

Francis Daly francis at daoine.org
Tue Mar 29 01:57:21 MSD 2011


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
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list