簡體   English   中英

.htaccess RewriteRule 問題在這里

[英].htaccess RewriteRule issue here

好的,所以我在 .htaccess 文件中使用此代碼。 這是那里唯一的代碼,但它似乎根本不起作用,我知道我已經安裝並啟用了 mod_rewrite。

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

也試過這個:

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

好的,所以,我正在使用 news.php 到 output 一個我鏈接到其他地方的 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 功能? 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