0

根据我的 PHP 信息,我激活了以下 mod:

mod_rewrite 

我的 .htacess 文件中有以下规则

    RewriteRule    ^dev/bloglic_script.js   dev/bloglicscriptreplacer.php?ip=%{REMOTE_ADDR}&ref=%{HTTP_REFERER}&country=DK

但是当我尝试查看代码时,出现以下错误:

    script src="dev/bloglic_script.js" type="text/javascript">
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /bloglic-2013/dev/bloglic_script.js was not found on this server.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at localhost Port 80</address>
</body></html>
</script>

谁能告诉我我错过了什么?

我的整个 Htacess 文件:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^dl/bloglic_script.js   dl/bloglicscriptreplacer.php?ip=%{REMOTE_ADDR}&ref=%{HTTP_REFERER}&country=DK
    RewriteRule    ^dev/bloglic_script.js   dev/bloglicscriptreplacer.php?ip=%{REMOTE_ADDR}&ref=%{HTTP_REFERER}&country=DK
    RewriteRule    ^cake/index.php/tags/addTag   cake/index.php?%{QUERY_STRING}&website=%{HTTP_REFERER} [L]
    RewriteRule    ^cake/index.php/tags/deleteTag   cake/index.php?%{QUERY_STRING}&website=%{HTTP_REFERER} [L]
    RewriteRule    ^script/bloglic_script.js   script/scriptreplacer.php?ip=%{REMOTE_ADDR}&ref=%{HTTP_REFERER}
#    RewriteCond     %{HTTP_USER_AGENT}  MSIE
#    RewriteRule    ^script/bloglic_script.js   script/scriptreplacer.php?ip=%{REMOTE_ADDR}&ref=%{HTTP_REFERER}&ie=1

  #  RewriteRule    ^$ cake/index.php/$1?%{QUERY_STRING}
</IfModule>

更新

在我的文件中进行了更改,现在我收到以下错误:

    <script src="dev/bloglic_script.js" type="text/javascript">
Reload the page to get source for: http://localhost/bloglic-2013/dev/bloglic_script.js
</script>

但是,无论我刷新多少,它仍然不起作用

4

1 回答 1

1

路径/bloglic-2013/dev/bloglic_script.js不会触发此规则,因为^从头开始的方式,在这种情况下,开头是bloglic-2013,而不是dev

如果您更改规则以包含前导目录,它应该触发。您只需要确保重写的路径是正确的。

RewriteRule    ^bloglic-2013/dev/bloglic_script.js   dev/bloglicscriptreplacer.php?ip=%{REMOTE_ADDR}&ref=%{HTTP_REFERER}&country=DK
于 2013-08-02T15:12:29.057 回答