doujiaochan7317 2012-08-15 01:23 采纳率: 0%
浏览 31
已采纳

htaccess重复file_put_contents

i created a log class. All works fine and the method "add" appends data to X.log. The problem is, when i turn on htaccess, file_put_contents wrote 2 lines (not one).

Basically, i tryed without class, only writing a file_put_contents in index + htaccess, and ever duplicate the log.

The problem looks like a htaccess routing twice.

This is the minimal code:

index.php:

DEFINE('BASE_PATH',dirname(__FILE__));
DEFINE('DS',DIRECTORY_SEPARATOR);
DEFINE( 'LOG_PATH' , BASE_PATH . DS . "var" . DS . "log" . DS );
file_put_contents(LOG_PATH."1.log", "hola".PHP_EOL, FILE_APPEND | LOCK_EX);
die();

.htaccess code:

Options +FollowSymLinks
IndexIgnore */*
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/(var|skin|js)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>

Thanks for help!.

  • 写回答

2条回答 默认 最新

  • dongyanghan0556 2012-08-15 01:28
    关注

    Your browser requests favicon.ico. And likely you don't have one - so request is being rewritten to index.php thus you have more than 1 record added.

    Just look at your access.log and see the actual urls requested.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序