簡體   English   中英

對url進行htaccess修改會在Chrome Inspector控制台中導致引導源地圖上的無休止javascript循環錯誤

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM