: Redirecting subdomain to root index.php I am new to this. Here is the situation and I'm wondering if someone can suggest the best solution to it: I have a domain www.mydomain.com where I have
I am new to this. Here is the situation and I'm wondering if someone can suggest the best solution to it:
I have a domain mydomain.com where I have a Magento website running, we are in development stage so I did URL forwarding mydomain.com to mydomain.net and we have an under-construction page on mydomain.net because we do not want to show development.
I also have a sub domain beta.mydomain.com which I pointed to mydomain.com/index.php which works fine.
But how can I show this without changing the URL in a browser from beta.mydomain.com to mydomain.com/index.php? This is in order to show our development to management.
More posts by @BetL925
3 Comments
Sorted by latest first Latest Oldest Best
This will redirect a subdomain to another domain or root domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursubdomain.yourdomain.com$ [NC]
RewriteRule ^(.*) www.newdomain.com/ [L,R]
if you want to show mydomain.com/index.php website content to beta.mydomain.com sub domain or beta.mydomain.com website content to mydomain.com/index.php?
Simple change domain content path (folder where you website located) from your hosting panel.
Why not use .htaccess and allow only people from your company network (IP's or domain) access to view the website?
If I understood your question correctly, a solution to your problem can be found in this Stack Overflow question. Assuming you're using a single Apache instance for all your sites, you can tell mod_rewrite that you're doing a rewrite instead of a redirect by removing the R flag from the RewriteRule:
# Example of internal redirect
RewriteRule (.+)$ "?url=" [L,R=301]
# Example of internal rewrite
RewriteRule (.+)$ "?url=" [L]
More info about rewrite vs. redirect in this thread. I believe the fact that you're using different domains (or domain/subdomain) will not be an issue, at least I haven't seen anything in the docs, but I'm not sure. Quote about absolute URLs:
If an absolute URL is specified, mod_rewrite checks to see whether the hostname matches the current host. If it does, the scheme and hostname are stripped out and the resulting path is treated as a URL-path. Otherwise, an external redirect is performed for the given URL. To force an external redirect back to the current host, see the [R] flag below.
Now, if you're using a different Apache instance for each site (or some other configuration - I assumed you're using Apache because of the htaccess tag) then I'm afraid I can't help you.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.