Welcome! Log In Create A New Profile

Advanced

rewrite rule help.

Steve Zhuo
March 31, 2011 11:02PM
hi

i'm running nginx with tomcat. I tried to rewrite all the incoming url
with /en appended. ex: www.example.com/main/index.html will get rewrite
to www.example.com/en/main/index.html

Following is my nginx config:


upstream www.example.com {
server localhost:8080;
}

location ^~ / {
index index.html index.htm;
rewrite ^ http://www.example.com/en$request_uri break;
}

location ^~ /en {
index index.html index.htm;
proxy_pass http://www.example.com/;
}

When i just do www.example.com/main/index.html, it rewrites to the new
url and page shows. But when i tried to write an url without .htm or
..html extension, the browser complains about page not found and return
404. such as "www.example.com/main/new" I got the 404 error on my
Tomcat log. Before this rewrite rule, the page can be loaded without
any problem.

here is my tomcat config:

<servlet-mapping>
<servlet-name>dir</servlet-name>
<url-pattern>*.htm</url-pattern>
<url-pattern>/en/*</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/errors/503.htm</location>
</error-page>


any help is apprecaite.


Thank You

Steve Zhuo

--
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite rule help.

Steve Zhuo March 31, 2011 11:02PM

Re: rewrite rule help.

Igor Sysoev April 01, 2011 02:24AM

Re: rewrite rule help.

Steve Zhuo April 01, 2011 04:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 221
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready