come da titolo tramite la funzione fwrite sto scrivendo un file.htaccess partendo da dei dati presenti in un database
devo fare una funzione che resetti il file,cancellando tutto ciò che si trova dopo le prime 3 righe,sapete darmi un input o un aiuto?codice:$file='./.htaccess'; $data = $this->db->query('SELECT * FROM alias_sef'); $string=""; foreach($data->result_array() as $record){ $string .="Redirect 307 /".$record["URL_SEF"]." ".$record["URL_TARGET"]."\n"; } $rewrite="RewriteEngine on RewriteCond $1 !^(index\.php|images|css|upload|js|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] ".$string.""; if (!$handle = fopen($file, 'r+')) { return false; } fwrite($handle, $rewrite); fclose($handle); return true; }

Rispondi quotando