Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Creating and sending a .htaccess file to a server

    ok so im currently using the code:

    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.
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    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:

    PHP Code:
    $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); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •