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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:36:54+00:00 2026-06-02T21:36:54+00:00

i just want to ask a quick question about .htaccess. Here’s how my webhosting

  • 0

i just want to ask a quick question about .htaccess.

Here’s how my webhosting works with subdomains…

Once i create a subdomain… then they create a folder into the root folder like this…

www.mydomain.com ---> public_html
sub.mydomain.com ---> public_html/sub

What i want to do is… to redirect all request from sub.mydomain.com to http://www.mydomain.com with some GET variable or something to identify from what subdomain the request is coming from…

So for example… when i get a requests to work like this

http://sub.mydomain.com/myphp.php ---> http://www.mydomain.com/myphp.php?comingfrom=sub
http://sub.mydomain.com/(anyUrl)  ---> http://www.mydomain.com/(anyUrl)?comingfrom=sub

I’m also wondering if this would execute some .htaccess redirects present in the main domain…

Hope you guys could help me…

Thanks in advance…

  • 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-02T21:36:55+00:00Added an answer on June 2, 2026 at 9:36 pm

    Put a .htaccess with following content into your subdomain folders:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
    RewriteRule ^(.*) http://www.mydomain.com$1?comingfrom=%1 [QSA,R=301,L]
    

    (untested, sorry)

    EDIT:

    you pointed out that you would like to keep the subdomain in your addressbar and don’t want a redirect. So you need to make a view changes to your <VirtualHost> of http://www.mydomain.com like so

     <VirtualHost ...:80>
       ServerName www.mydomain.com
       ServerAlias mydomain.com
       ServerAlias sub.mydomain.com
    
       DocumentRoot /path/to/your/docroot/of/www.mydomain.com
    
       RewriteEngine On
       RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
       RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
       RewriteRule ^(.*) $1?comingfrom=%1 [QSA,PT,L]
     </VirtualHost>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first here in Stackoverflow. So I just want to ask question
just want to ask anyone here can solve this problem? I want to create
I don't know too much about encryption, I just want to ask, which method
I just want ask for your comments/suggestions on how to create a customized listview
I want to ask quick question, i want to make a select drop down
I just want to ask something about my code. #define LIM 40 main() {
I just want to ask a simple question, as I don't imagine how to
Just want to ask the gurus out there about this. I know that CSS
I just want to ask a simple question related the GLSurfaceView and drawn objects
Just want to ask can netbean IDE get connected to clearcase remote client 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.