[英]htaccess modification for pretty urls causes endless javascript loop on bootstrap sourcemap error in Chrome Inspector console
.htaccess mods的初学者,可处理漂亮的URL。
我有一个php / bootstrap / mysql / javascript页面: http://localhost/modules/posts/questions_all.php 。
我想将http://localhost/modules/posts/questions_all.php/1234之类的页面重定向到原始页面。
我已经修改了.htaccess文件。
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^modules/posts/questions_all.php/?$ modules/posts/questions_all.php [NC,L]
它似乎重定向到原始页面,但会产生某种类型的无尽javascript循环,该循环会不断地将部分代码附加到页面的混乱中。
在Chrome控制台检查器中,我收到此错误,该错误在页面的正常加载中不会发生。 但是,URL末尾带有/ 1234时,错误为:
DevTools failed to parse SourceMap: http://localhost/modules/posts/questions_all.php/bootstrap.min.js.map
[Violation] Forced reflow while executing JavaScript took 32ms
原始页面不会出现对SourceMap的请求,该页面运行正常,没有控制台错误。
这似乎也发生在firefox中,所以我不认为要关闭Chrome Inspector中的SourceMap功能吗? 在未启用Chrome检查器的情况下,我仍然遇到此问题。
我已经使用htaccess mods的相同方法来访问其他类似页面(带有引导程序)以获取漂亮的URL,但是我没有收到该错误,并且它们可以正常工作,但是此页面不是...!
先感谢您!
[编辑]:发现的问题以某种方式与无限滚动的代码有关,但仍不确定为什么会出现无限循环。 代码的目的是连续加载数据,直到到达屏幕底部,然后停止。 在不将/ 1234添加到URL的情况下,它可以正常工作,但是在添加/ 1234时,它似乎陷入了无限循环,并导致代码的其他部分也执行。
load_data函数是一个AJAX调用,用于检索数据。
代码如下:
//autoload portion. when scrolling reaches the bottom of the screen, triggers another load of data
$(window).scroll(function(){
if($(window).scrollTop() + $(window).height() > $("#load_data").height() && action == 'inactive'){
action = 'active';
start = start + limit;
setTimeout(function(){
load_data(limit, start, search, tag);//recursive loading function
}, 500);
}
});
似乎上面的EDIT不是问题。 相反,它是AJAX调用函数中的URL参考。 不知道为什么,但是如图所示使用htaccess,该URL必须带有http:引用,然后才能正常工作。
$.ajax({
url:"questions_all_autoscroll_fetchdata.php" - original worked without htaccess mods, but no longer with htaccess mods
url:"/questions_all_autoscroll_fetchdata.php" - still did not work with htaccess mods
url:"http://localhost/modules/posts/questions_all_autoscroll_fetchdata.php" - worked fine with htaccess mods.
...});
如果有人可以提供解释,我将不胜感激。 另外,如果有一种方法可以使它与相对URL一起使用,则也知道它会更有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.