Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:26:52+00:00 2026-06-11T13:26:52+00:00

I’m looking for a way to manipulate the webserver PHP is running under, using

  • 0

I’m looking for a way to manipulate the webserver PHP is running under, using APIs.

For example, I’d like to be able to add mod rewrite rules dynamically or block IP addresses for certain paths, all without touching .htaccess files.

Does something like this exist for PHP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:26:53+00:00Added an answer on June 11, 2026 at 1:26 pm

    It is not possible for PHP to alter Apache’s config dynamically, although as you noted you can use PHP to edit the configuration or .htaccess files reload the configuration. But I would consider that a big security risk to give your webapp that much power over the web server.

    Your example of blocking IPs dynamically can be done with mod_rewrite’s RewriteMap directive. Basically, you would write a mod_rewrite rule for your website that will instruct mod_rewrite to look in an external data source that your PHP script could maintain.

    The mod_rewrite documentation has an example to start from: Denying Hosts in a Blacklist

    Description:
    We wish to maintain a blacklist of hosts, rather like hosts.deny,
    and have those hosts blocked from accessing our server.
    
    Solution:
    RewriteEngine on
    RewriteMap hosts-deny txt:/path/to/hosts.deny
    RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
    RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND
    RewriteRule ^ - [F]
    ##
    ## hosts.deny
    ##
    ## ATTENTION! This is a map, not a list, even when we treat it as such.
    ## mod_rewrite parses it for key/value pairs, so at least a
    ## dummy value "-" must be present for each entry.
    ##
    
    193.102.180.41 -
    bsdti1.sdm.de -
    192.76.162.40 -
    
    Discussion:
    The second RewriteCond assumes that you have HostNameLookups turned on,
    so that client IP addresses will be resolved. If that's not the case,
    you should drop the second RewriteCond, and drop the [OR] flag from
    the first RewriteCond.

    Your PHP script could maintain those text files (other data stores are available, too) and you could make any number of rulesets for your specific needs to control access dynamically. Would that work?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to count the length of a string with PHP. The string
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.