简体   繁体   English

.htaccess RewriteRule 问题在这里

[英].htaccess RewriteRule issue here

Ok, so I am using this code in a .htaccess file.好的,所以我在 .htaccess 文件中使用此代码。 This is the only code in there, but it doesn't seem to work at all and I know I have mod_rewrite installed and enabled.这是那里唯一的代码,但它似乎根本不起作用,我知道我已经安装并启用了 mod_rewrite。

RewriteEngine On
RewriteRule ^news\.js news.php [NC]

have also tried this:也试过这个:

RewriteEngine On
RewriteRule news.js news.php [NC]

Ok, so, I am using news.php to output a JS Script that I am linking to elsewhere.好的,所以,我正在使用 news.php 到 output 一个我链接到其他地方的 JS 脚本。 So I want all links to news.js (and all links with text after this), to point to news.php instead.因此,我希望所有指向 news.js 的链接(以及在此之后的所有文本链接)都指向 news.php。 And so news.php outputs the Javascript for this, but is a PHP file...等等 news.php 为此输出 Javascript,但它是 PHP 文件...

Am I setting up the PHP file correctly?我是否正确设置了 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

?>

The problem is that it isn't working.问题是它不起作用。 Can someone please help me?有人可以帮帮我吗? Is my .htaccess file not set up properly?我的 .htaccess 文件是否设置不正确?

Thanks for any help you can offer me.感谢您为我提供的任何帮助。

do you have AllowOverride enabled for your .htaccess to work?您是否为 .htaccess 启用了 AllowOverride 功能? http://www.blackbeagle.com/web-hosting/apache-mod_rewrite-and-allowoverride/ http://www.blackbeagle.com/web-hosting/apache-mod_rewrite-and-allowoverride/

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

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