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

  • Home
  • SEARCH
  • 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 7515363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:47:02+00:00 2026-05-30T00:47:02+00:00

On shared web-hosting my software supports multiple domains (all domains point to the same

  • 0

On shared web-hosting my software supports multiple domains (all domains point to the same public_html root directory).

What I want to do is keep redirects (and any RedirectMatch) in their own host specific/dedicated .htaccess file.

Visually the directory structure looks like this…

/public_html/ (all domains are pointed internally to this directory)

/public_html/.htaccess

/public_html/www.example1.com/

/public_html/www.example2.com/

/public_html/www.example3.com/

There are two approaches I’m considering though would appreciate input from others:

The first would be to keep domain specific redirects out of the main .htaccess file as defined above. So I’d like to have redirects handled by the .htaccess files as defined by below if possible…

/public_html/www.example1.com/.htaccess

/public_html/www.example2.com/.htaccess

/public_html/www.example3.com/.htaccess

…if this is not feasible I’ll settle for a rewrite to a PHP file to hand off redirects to PHP instead. I imagine this isn’t as performance oriented though on the other hand it would give me the opportunity to log redirects and see how long it takes them to level off.

Some clarifications:

  1. I’m using shared web hosting so anything Apache related needs to be done through .htaccess files only.

  2. There are no redirects/matches in the master .htaccess file nor will there ever be since two domains may eventually attempt to use the same redirect.

  • 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-30T00:47:03+00:00Added an answer on May 30, 2026 at 12:47 am

    Since you are on shared host, You cannot afford to have any solutions concerning conf files (which BTW are better). So wont bother to list them. Best way to do the above is like this:

    The code was written keeping in mind that none of the domains share any kind of file/data on the server. Every file/data pertaining to a domain is kept under a folder having the name equal to its domainname.

    The code below is tested(both static and non static):

    RewritEngine on
    RewriteBase /
    
    RewriteCond %{ENV:REDIRECT_STATUS} 200
    RewriteRule ^ - [L]
    

    And add either of the following to the above:

    for doing it statically:

    RewriteCond %{HTTP_HOST} ^www\.(example1|example2|example3)(\.com)$ [NC]
    RewriteRule ^(.*)$ /www.%1%2/$1 [L]
    

    for doing it statically: and also if you want to access the site without www

    RewriteCond %{HTTP_HOST} ^(www\.)?(example1|example2|example3)(\.com)$ [NC]
    RewriteRule ^(.*)$ /%1%2%3/$1 [L]
    

    for Non-statically do it: this is a better sol

    RewriteRule ^(.*)$ /%{HTTP_HOST}/$1 [L]
    

    All the above will do is redirect URI to their specific domain’s folder. All other domain specific rewrites can be handled in the respective folders.

    If you have URIs without the www, i.e. example1.com change ^www\.(example1|example2|example3)(\.com)$ to ^(www\.)?(example1|example2|example3)(\.com)$

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

Sidebar

Related Questions

On shared web-hosting my software supports multiple domains (all domains point to the same
Recently our Web hosting provider moved to a medium trust level for all shared
I have a mvc 3 web app, but my shared web hosting company supports
I am having a frequent problems with my web hosting (its shared) I am
i just deployed my php/mogodb website (php part in a shared web hosting, and
I have installed a PHP application onto a shared hosting web server. I am
I am porting a large web application to a shared web hosting environment. The
I was curious if there is a shared hosting platform for asp.net web sites
I'm developing a game in PHP+Mysql that is hosted in a shared web hosting.
I am learning how to setup a shared hosting web server. As a server

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.