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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    67
    Thanks
    20
    Thanked 1 Time in 1 Post

    Way to automatically update .htaccess?

    I was wondering if there is a way to automaticly update a .htaccsess file. Prehaps using PHP fopen() & fwrite().

    What I would like to be able to do is allow users to create a new article, but I need a way to redirect the domain path they wanted to a page like article.php?id=56985689.

    For ovbious reasons I don't want to do this by hand, so I was wondering if there is a way to automate this? Any ideas?

  • #2
    New Coder
    Join Date
    Sep 2011
    Posts
    80
    Thanks
    0
    Thanked 13 Times in 12 Posts
    Yep, you pretty much answered your own question by suggesting fwrite.

    What exactly are you trying to achieve? There maybe a simpler solution.

  • #3
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Uh, I'd think twice about rewriting .htaccess dynamically. That's extremely risky, especially if there's a security vulnerability in your website. You don't want someone else to take control of .htaccess, do you?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Agreed. While it can be done, its not exactly the wisest.
    Find a common format, and use the rewrite engine to send it to article.php?id=xxxx.


  •  

    Posting Permissions

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