Brand new to the world of .htaccess modifications and handling clean URLs.
I currently have a php/bootstrap/mysql/javascript page at: http://localhost/modules/posts/questions_all.php.
I am interested in redirecting pages such as http://localhost/modules/posts/questions_all.php/1234 back to the original page.
I've made changes to my .htaccess file as follows:
RewriteEngine On # Activate the rewriting engine
RewriteRule ^modules/posts/questions_all.php/?$ modules/posts/questions_all.php [NC,L]
The redirection seems to work but it triggers an endless loop of javascript that repeatedly adds portions of code, making the page messy.
In the Chrome console inspector, I encounter an error that doesn't occur when the page loads normally. However, with /1234 added to the end of the URL, the error message is:
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 does NOT happen on the original page, which functions flawlessly without console errors.
This issue also arises in firefox, so it doesn't seem to be related to disabling the SourceMap feature in the Chrome Inspector. Even with the Chrome inspector turned off, the problem persists.
I have employed similar .htaccess modifications for other pages (with bootstrap) to achieve clean URLs without encountering this error. It seems to be specific to this particular page...!
Thank you in advance for any assistance!
[EDIT]: Upon further investigation, the problem appears to be linked to an infinite scroll script, though it's still unclear why it causes an infinite loop. The purpose of the script is to dynamically load content until reaching the bottom of the screen, then halt. Everything works fine without the addition of /1234 to the URL, but once it's included, the script enters into an infinite loop and executes other parts of the code as well.
The load_data function initiates an AJAX call to fetch data.
Below is the relevant code snippet:
//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);
}
});