1

I've done searching for my answer and have tested a few solutions, but nothing has worked so far.

I'm trying to get a URL like this http://baseball.sports.com to rewrite to http://pro.sports.com/baseball-index.php.

However, I still need to keep the domain the same (http://baseball.sports.com). The reason being I have about 5 subdomains (baseball, football, soccer, etc.) that I want to run off the same code base (pro.sports.com).

Everything is on the same server. I'd be happy to answer any other questions that would help me get a resolution.

I truly appreciate any direction that can be given to me to solve this.

  • What are the solutions you have tested already but didn't work? – Henning Makholm Nov 5 '12 at 21:06
  • Where is the webroot for baseball.sports.com and pro.sports.com? Are they the same directory? – Jon Lin Nov 5 '12 at 23:38
  • if your directory structure on hosting is like /home/username/pro/ (for pro subdomain) and /home/username/baseball/, you can use same code on any domain by including source from real path. – Aleksandar Dec 15 '14 at 16:20
1

i think you should ask your host about Wildcard

https://codex.wordpress.org/Configuring_Wildcard_Subdomains http://en.wikipedia.org/wiki/Wildcard_DNS_record

1

Your best bet is to create an index.php and place it in your web root folder (normally named public_html) that is connected with the website http://baseball.sports.com.

That index.php file must contain a script to load contents from the other website you're trying to link to.

This PHP code might work well for you:

<?php
echo file_get_contents("http://pro.sports.com/baseball-index.php");
?>

If not, then you should research the CURL library, especially if the other website involves secure forms you want users to fill in, etc...

0

Rewrite rules won't work across sub-domains, even on the same server.

You could use mod_proxy to make this happen. Configure baseball.sports.com to proxy the information that you want from the other subdomain.

0

You are looking for something pretty similar to me.

This code worked (it redirects the user to a new link) but it needs some polish

Options +FollowSymlinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com
RewriteRule ^(.*)$ /%1-index.php [L,NC]
</IfModule>

So this should redirect someone entering to "baseball.example.com" to example.com/baseball-index.php

Best regards

PS: Credits to Dave Lozier (Redirect subdomain to folder without changing the URL)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy