简体   繁体   English

对url进行htaccess修改会在Chrome Inspector控制台中导致引导源地图上的无休止javascript循环错误

[英]htaccess modification for pretty urls causes endless javascript loop on bootstrap sourcemap error in Chrome Inspector console

Beginner at .htaccess mods and handling pretty URLs. .htaccess mods的初学者,可处理漂亮的URL。

I have a php/bootstrap/mysql/javascript page: http://localhost/modules/posts/questions_all.php . 我有一个php / bootstrap / mysql / javascript页面: http://localhost/modules/posts/questions_all.php

I would like to redirect pages like http://localhost/modules/posts/questions_all.php/1234 to the original page. 我想将http://localhost/modules/posts/questions_all.php/1234之类的页面重定向到原始页面。

I have modified the .htaccess file as such. 我已经修改了.htaccess文件。

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^modules/posts/questions_all.php/?$    modules/posts/questions_all.php    [NC,L] 

It seems to redirect to the original page but produces some type of endless javascript loop which appends portions of the code over and over again creating a mess of a page. 它似乎重定向到原始页面,但会产生某种类型的无尽javascript循环,该循环会不断地将部分代码附加到页面的混乱中。

In the Chrome console inspector, I get this error which does not occur in the normal load of the page. 在Chrome控制台检查器中,我收到此错误,该错误在页面的正常加载中不会发生。 But with /1234 at the end of the URL, the Error is: 但是,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

The request for the SourceMap did NOT occur with the original page, which functioned perfectly without console errors. 原始页面不会出现对SourceMap的请求,该页面运行正常,没有控制台错误。

This seems to happen in firefox as well, so I don't think it is a matter of turning off the SourceMap feature in the Chrome Inspector? 这似乎也发生在firefox中,所以我不认为要关闭Chrome Inspector中的SourceMap功能吗? With the Chrome inspector NOT engaged, I still get this problem. 在未启用Chrome检查器的情况下,我仍然遇到此问题。

I have used the same approach for htaccess mods to other similar pages (with bootstrap) for pretty URLs, but I do not get that error and they function fine, but not this page...! 我已经使用htaccess mods的相同方法来访问其他类似页面(带有引导程序)以获取漂亮的URL,但是我没有收到该错误,并且它们可以正常工作,但是此页面不是...!

Thank you in advance! 先感谢您!

[EDIT]: the found issue is somehow related to an infinite scroll piece of code, but still am not sure why I get an infinite loop. [编辑]:发现的问题以某种方式与无限滚动的代码有关,但仍不确定为什么会出现无限循环。 Purpose of code is to continuously load data until the bottom of the screen is reached, then stops. 代码的目的是连续加载数据,直到到达屏幕底部,然后停止。 It works fine without the /1234 added to the URL, but when /1234 is added, it seems to go into an infinite loop and causes other parts of the code to execute as well. 在不将/ 1234添加到URL的情况下,它可以正常工作,但是在添加/ 1234时,它似乎陷入了无限循环,并导致代码的其他部分也执行。

The load_data function is an AJAX call to retrieve data. load_data函数是一个AJAX调用,用于检索数据。

Code below: 代码如下:

//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);
        }
    });

Seems like the EDIT above was not the problem. 似乎上面的EDIT不是问题。 Instead, it was the URL reference in the AJAX calling function. 相反,它是AJAX调用函数中的URL参考。 Not sure why, but using htaccess as shown, the url had to be complete with http: reference, then it worked fine. 不知道为什么,但是如图所示使用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.

...});

If someone can provide an explanation, I would appreciate it. 如果有人可以提供解释,我将不胜感激。 Also, if there is a way to make it work with the relative url, it would be more helpful to know also. 另外,如果有一种方法可以使它与相对URL一起使用,则也知道它会更有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM