Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess重写此处的规则问题_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache .htaccess重写此处的规则问题

Apache .htaccess重写此处的规则问题,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,好的,我在.htaccess文件中使用了这段代码。这是其中唯一的代码,但它似乎根本不起作用,我知道我已经安装并启用了mod_rewrite RewriteEngine On RewriteRule ^news\.js news.php [NC] 我也尝试过这一点: RewriteEngine On RewriteRule news.js news.php [NC] 好的,我正在使用news.php输出一个JS脚本,我正在链接到其他地方。因此,我希望所有指向news.js的链接(以及后面有文本

好的,我在.htaccess文件中使用了这段代码。这是其中唯一的代码,但它似乎根本不起作用,我知道我已经安装并启用了mod_rewrite

RewriteEngine On
RewriteRule ^news\.js news.php [NC]
我也尝试过这一点:

RewriteEngine On
RewriteRule news.js news.php [NC]
好的,我正在使用news.php输出一个JS脚本,我正在链接到其他地方。因此,我希望所有指向news.js的链接(以及后面有文本的链接)都指向news.php。所以news.php输出了Javascript,但是它是一个php文件

我是否正确设置了PHP文件

<?php

// If there is a php error for any reason...hide it!
ini_set('display_errors', 'Off');

// Set the header-type.
header('Content-type: application/x-javascript');

// And it calls some functions in here

?>

问题是它不起作用。有人能帮我吗?是否未正确设置我的.htaccess文件


感谢您能为我提供的任何帮助。

您是否已为您的.htaccess工作启用了AllowOverride

它不起作用,需要更多的解释。在浏览器中打开news.js时会发生什么?你有404错误吗?没有错误,我什么都没有。javascript代码可以工作,所以我不明白为什么它不能工作。如果我将调用链接到news.php文件,它工作得很好,但是链接到news.js根本不起作用。@Solo:我的意思是,当你输入
http://url/to/news.js
在浏览器地址栏中,或者它是否发送预期的javascript内容?请尝试。URL是这样的:它以脚本文件的形式显示内容很好,但由于某种原因,当我在文件中使用它时,它不起作用。solo:一切正常,Apache配置或代码中可能没有任何错误。有一件事:在包含news.js或news.php的页面中,是否也包含其他javascript文件?例如定义setDPNews/setDPVersion函数的函数?因此如果我使用
Options+FollowSymlinks
这也不起作用。