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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:13:58+00:00 2026-06-11T08:13:58+00:00

On my website i’m using virtual host so my users can have virtual domain

  • 0

On my website i’m using virtual host so my users can have virtual domain like ‘user1.mydomain.com’, ‘user2.mydomain.com’,…

The problem is that on virtual domains like ‘user1.domain.com’ the index page is always the same as on my index page ‘http://mydomain.com’.

What i want to do is to have two different index pages for the domain and for subdomains. My question, how to have subdomains redirected to ‘index2.php’ (for example) and still have the subdomains to look like ‘user1.mydomain.com’?

  • 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-11T08:14:00+00:00Added an answer on June 11, 2026 at 8:14 am

    Ideally, you would set up completely separate document directories for each subdomain. vhost in apache is the way to go. If you however want to do it your way (subdomains redirecting to individual files), then it’s a bit more work, but is still doable. First, define the mod_vhost with wildcard:

    <VirtualHost 111.22.33.55>
        DocumentRoot /www/subdomain
        ServerName www.mydomain.com
        ServerAlias *.mydomain.com
    
        ...
    </VirtualHost>
    

    Then inside this VirtualHost setup rewrite rules using mod_rewrite:

    <Location "/">
        RewriteCond %{HTTP_HOST} ^user1.mydomain.com$
        RewriteRule ^\/$ http://www.mydomain.com/index2.php [R=301,L]
        RewriteRule ^\/index.php$ http://www.mydomain.com/index2.php [R=301,L]
    
        RewriteCond %{HTTP_HOST} ^user2.mydomain.com$
        RewriteRule ^\/$ http://www.mydomain.com/index3.php [R=301,L]
        RewriteRule ^\/index.php$ http://www.mydomain.com/index3.php [R=301,L]
    
        ...
    </Location>
    

    Note however that this will only work properly for / and /index.php requests to subdomains. You are much better off setting up separate document root directories for each subdomain if you intend to do anything more than this.

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

Sidebar

Related Questions

Website: http://videojs.com/ How can I use the YouTube Skin on the frontpage? I'd really
Website in reference: http://www.imvu-e.com/products/ht/clients/test/ Notice on the tables how I have a newline separating
Website. This feels like a common problem, but it's a difficult one to Google!
Website using .NET Framework v3.5, SQL Server 2008, written in C# I have a
My website, http://kenthomes.com.au/test/gallery.php , works fine in normal browsers like FF, Chrome, Safari and
My website can be view from 2 different kind of URI: www.mywebsite.com/magazine or www.mywebsite.com/index.php/magazine
Website is running on a web host where we don't have access to a
Website needs to have a url of www.siteurl.com/file.pdf It will only every be this
Website is PHP/mySQL. Some of the pages (inventory) have friendly URLs. Great. The problem
Website in question: christianselig.com At the bottom of the page I have a message

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.