[英]how to trace where a javascript file request is coming from
好的,我的自定义模板有很多问题,甚至都不好笑...
这是joomla 3.x的自定义模板...
我想找出的一个问题是缺少的javascript请求来自哪里?
我尚未发布所有模块,甚至上传了带有一些更改的新模板...
但它仍然存在!
如果您查看源代码并单击所谓的丢失文件,它会很好显示...因此,为什么在Chrome的javascript控制台中它总是说404 !!
您如何确定请求的来源?
另外,我一直在视图源中看到它,但是不知道它是从哪里来的。
<script type="text/javascript">
window.addEvent('load', function() {
new JCaption('img.caption');
});
</script>
编辑...
为了弄清楚我在说什么文件,就是这个文件:
<script src="/social/services/templates/testingdifferentversion16/js/jquery-1.10.1.min.map.js" type="text/javascript"></script>
如果您查看视图源,则可以很好地访问它。
如果看到找不到它的错误,因此出现404,则文件确实丢失。
这就是为什么这篇文章写起来,为了找到此请求的来源。
希望此编辑可以使事情变得更简单。
编辑2(根据morantis的要求)
##
# @package Joomla
# @copyright Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
# @license GNU General Public License version 2 or later; see LICENSE.txt
##
##
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
##
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
## Mod_rewrite in use.
RewriteEngine On
## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects
##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##
# RewriteBase /
## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.
检查根目录中是否有.htaccess文件,然后检查该文件中是否有mod_rewrite规则。 许多CMS软件包都使用mod_rewrite来处理整个站点的导航。 如果您正在使用Filezilla for FTP之类的程序,请确保该程序在选项中设置了“显示隐藏文件”,否则您甚至可能看不到.htaccess文件。 如果有,请在您的问题中张贴其内容。
我很快看了一下,是的,Joomla确实使用了mod_rewrite来控制网站中的流量,并且由此产生了多个错误。
http://forum.joomla.org/viewtopic.php?f=304&t=346374
这是一个与您的问题不完全相同的链接,但它确实使您了解如何使用.htaccess弄乱事情。 给我更多信息,我们将继续。
好吧,如果您尝试访问此文件,则必须将其直接放在地址栏中。 如果查看mod_rewrite规则,您将看到,如果URL以“ /”结尾或不以扩展名结尾,那么它将在其末尾添加“ index.php”。
那有意义吗?
@ user2730725这也让我发疯了! 该文件是.map文件,仅用于调试目的。 通过打开Chrome Dev Tools,然后依次单击“设置”和“常规”中的“启用JS源映射”复选框,关闭尝试检索它的设置。 取消选择。 问题解决了。 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.