Javascript being loaded twice after enabling rewrite through Tomcat valve

蹲街弑〆低调 提交于 2019-12-12 04:21:52

问题


I have a single page application, and I am using the tomcat rewrite valve to forward all the requests other than static resources to my index.html. Following are the contents of my rewrite.config:

RewriteCond %{REQUEST_URI} (?!.*\.(?:jpg|png|css|js|json|scss|map)$).*$
RewriteRule ^.*$ /index.html [L,QSA]

After getting the rewrite to work, I am seeing that my jQuery library, and other javascript files are loading twice. This is causing the application to break. Could someone point out what could be the potential root cause of this issue?


回答1:


I found out the issue using this answer: link The issue was that I was missing some of the file tags. My final rewrite rule looks like this:

RewriteCond %{REQUEST_URI} (?!.*\.(?:jpg|png|css|js|json|htm|scss|map|svg|html|favicon\.ico)$).*$
RewriteRule ^.*$ /index.html [L,QSA]


来源:https://stackoverflow.com/questions/41528846/javascript-being-loaded-twice-after-enabling-rewrite-through-tomcat-valve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!