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 7543847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:32:01+00:00 2026-05-30T08:32:01+00:00

I was given a VM at my company to install web software on. But

  • 0

I was given a VM at my company to install web software on. But I came across a rather bizarre issue where PHP variables would be overwritten (rewritten) by the server if they matched a specific pattern. What could rewrite PHP variables like this?

The following is as an entire standalone script.

<?php
$foo = 'b.domain.com';
echo $foo; // 'dev01.sandbox.b.domain.com'

$bar = 'dev01.sandbox.domain.com';
echo $bar; // 'dev01.sandbox.sandbox.domain.com'

$var = 'b.domainfoo.com';
echo $var; // 'b.domainfoo.com' (not overwritten because it didn't match whatever RegEx has been set)
?>

Essentially any variable which contains a subdomain and matches on the domain name would be rewritten. This isn’t something mod_rewrite would be able to touch, so it has to be something at the server level that is parsing out PHP and rewriting a string if it matches a RegEx.

  • 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-05-30T08:32:02+00:00Added an answer on May 30, 2026 at 8:32 am

    Output overwriting is possible within Apache by using mod_perl: PerlOutputFilterHandler.

    The following could be added to an apache.conf to set the output filter:

    <FilesMatch "\.(html?|php|xml|css)$">
        PerlSetVar Filter On
        PerlHandler MyApache2::FilterDomain
        PerlOutputFilterHandler MyApache2::FilterDomain
    </FilesMatch>
    

    Example filter handler code:

    #file:MyApache2/FilterDomain.pm
    #--------------------------------
    package MyApache2::FilterDomain;
    
    use strict;
    use warnings;
    
    use Apache2::Filter();
    use Apache2::RequestRec();
    use APR::Table();
    
    use Apache2::Const -compile => qw(OK);
    
    use constant BUFF_LEN => 1024;
    
    sub handler {
        my $f = shift;
        my @hostname = split(/\./, $f->r->hostname);
        my $new_hostname = $hostname[0].".".$hostname[1];
    
        unless ($f->ctx) {
            $f->r->headers_out->unset('Content-Length');
            $f->ctx(1);
        }
    
        while ($f->read(my $buffer, BUFF_LEN)) {
            $buffer =~ s/([a-z0-9]+)+\.domain\./$new_hostname\.$1.domain\./g;   
            $f->print($buffer);
        }
    
        return Apache2::Const::OK;
    }
    1;
    

    More on Apache mod_perl filters can be found here: mod_perl: Input and Output Filters

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

Sidebar

Related Questions

given the URL of a well known company (eg http://mcdonalds.com/ ), how would you
My company has given me a PDF that's already been mastered, packaged, etc. but
Given the following HTML form: <form id=myform> Company: <input type=text name=Company value=ACME, INC./> First
I'd like to extract as many tweets containing a given keyword (typically a company
Here I had very similar xml structure, but now I have this: <Fields> <Company>My
Given the classes Company , Employee , and Car what is the preferred practice
My company develop web apps using combination of mod_perl, axkit and apache. We have
Our company's switching from traditional, lame Windows shared drive to a Linux install of
My company develops an IT-infrastructure management software, that we mostly use in Ukraine. Our
A little background first - When I do apt-get install downloads from my company

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.