...

View Full Version : Creating and sending a .htaccess file to a server



danielwarner
08-30-2006, 12:36 AM
ok so im currently using the code:


RewriteEngine on

RewriteRule ^example/example/$ index.php?example=example
RewriteRule ^example/example/$ index.php?example=example
RewriteRule ^example/example/$ index.php?example=example
RewriteRule ^example/example/$ index.php?example=example

Now this all works fine but what i would like to do is automaticly update this along with my database (through my cms). I know its possible to edit a pages contents in php and im pretty sure its possible to create a new page. My question here is how can i do this using php? I can handle the database side of this. (generating the RewriteRules from querys) but if anyone can help me with creating the new page and dropping it onto my server then i would be very greatful.

Thanks for your time.

Anthony2oo4
08-30-2006, 02:37 AM
i know how to write files but im not sure if you can write htaccess files. If its possible here is how id do it:


$FileName = ".htaccess";

$Hanndle = fopen($FileName, 'w') or die("can't open file");

$Data = "RewriteEngine on\n";
$Data .= "RewriteRule ^example/example/$ index.php?example=example\n";
$Data .= "RewriteRule ^example/example/$ index.php?example=example\n";
$Data .= "RewriteRule ^example/example/$ index.php?example=example\n";
$Data .= "RewriteRule ^example/example/$ index.php?example=example\n";

fwrite($Handle, $Data);

fclose($Handle);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum