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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:37:44+00:00 2026-06-12T01:37:44+00:00

I am trying to build a reverse proxy using Apache. My goal is to

  • 0

I am trying to build a reverse proxy using Apache.
My goal is to proxy all requests of the form <subdomain>.domain.com/file.html to www.domain.com/<subdomain>/file.html.

I somehow need to capture the <subdomain> of the original URL and use it to construct the target URL.

I assume that I need an Apache directive that can match regular expressions on the whole URL, instead of the part of the url after %{HTTP_HOST}, since my target URL contains the original URL’s subdomain. For this reason I can’t use the ProxyPassMatch directive, since it only matches the part of the URL after %{HTTP_HOST}.

Another alternative is to use as many VirtualHost sections as my subdomains. But of course this solution doesn’t make sense, since my subdomains will keep increasing.

Any tips on how to tackle this?

  • 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-12T01:37:45+00:00Added an answer on June 12, 2026 at 1:37 am

    Ok, I managed to solve it using Rewrite rules.

    # Requires Apache module ``proxy_http``, ``rewrite``
    <VirtualHost *:80>
        ServerName primary.domain.com
        ServerAlias *.domain.com
    
        ProxyRequests Off
        <Proxy *>
             Order deny,allow
             Allow from all
        </Proxy>
    
        RewriteEngine On
    
        RewriteCond %{HTTP_HOST}/%{REQUEST_URI} ^(.*)\.domain\.com/(.*)$
        RewriteRule (.*)    http://www.domain.com/%1%2 [P]
    
     </VirtualHost>
    

    Basically what happens is this:

    • RewriteCond matches all incoming requests whose URL matches .domain.com/
    • RewriteRule proxies the request to the URL http://www.domain.com/%1/%2, where %1 and %2 are the subdomain and request uri of the original request, respectively.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying build a conditions array to be using in a prepared statement: Cars.find(:all,
I'm trying to build a reverse proxy with Netty, and I'd like to keep
I am trying to reverse engineer the build system of a commercial Windows based
Trying to build a Metro app using Javascript and having issues with IndexedDb. I
Trying to build my android project with Buildr (Apache), but can't find any info
I'm trying build this network connection using BroadcastReceiver. When connection doesnt exist it will
I am trying to start using source indexing alongside Git on our build server
I'm trying to build two seperate dictionaries with a file thats arranged in this
I am trying build a page, where a user can login using his google
I am trying build a jQuery EasyUI datagrid or treegrid out of a large

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.