Urlrewrite returns 404 error and css/js file path problem
Recent days, I'm working on how to increase the number of site visitors , and i wrote one post on -- How can I Increase the number of my Web Site Visitors? and atst, i try to do SEO on mysite. It says 'try static page , and remove ? , & in your url ' in SEO article. and it says we can try to use urlrewrite for those dynamic url links.
i tried urlrewrite on my site , everythings gone okay but sometimes page runs to 404 error. It's a strange error, i googled this problem. Finally, i resoloved it. That's the answer for it below.
If you keep your project with struts2 + urlrewrite. You should do some change at your web.xml
<dispatcher>FORWARD</dispatcher> <!--you should add this-->
btw, when we add urlrewrite functions, sometimes the absolut path of those css/js files in header code may need to be changed, like this:
www.abc.com/abc.action?id=123 (orginal link, we set 'Alink')
www.abc.com/abc/123 (the link after urlrewrite , we set 'Blink')
if Alink will return 'test.jsp' , and when run Blink, we may get error when loading thoes css/js files in test.jsp. we can try to load 'http://www.abc.com/xxx.css' replace, and we can try the code below too.
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Okay, more info about urlrewrite, you can follow this link