-1

I am helping someone with their site and they want a template page (example.com/template) shown on each of their subdomains.

So when a user navigates to a.example.com or b.example.com, etc.
they see example.com/template.php
but the url stays a.example.comor b.example.com, etc.

I know there is a way to do this I just can't figure it out.
Basically I want to be able to change all of the pages at once by making a change to 1 file.

I think I am close with this code but I keep get 500 errors
RewriteCond %{HTTP_HOST} ^$.example.com$ [NC]
RewriteRule ^$ $1.example.com/template.php

PS: these are actual domains, not virtual
This is what I currently have

RewriteEngine On
RewriteCond %{HTTP_HOST} ^.+\.dfwfamilylifenews\.com [NC]
RewriteRule ^$ /template.php [L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Ben Miller
  • 29
  • 7

1 Answers1

1

Firstly, make sure the rewrite module is loaded in Apache. See this answer for more info.

Second, you need to change your rules to:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^.+\.example\.com [NC]
RewriteRule ^$ /template.php [L]
Community
  • 1
  • 1
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Cloud hosted by DirectAdmin.com. I am unable to check the http.conf file, although he is running wordpress and they have their custom rules already in place, so I am pretty sure it is loaded. – Ben Miller Aug 14 '13 at 15:43
  • I am still not getting to the template.php page. I am still navigating to the actual subdomain. – Ben Miller Aug 14 '13 at 15:47
  • @BenMiller Make sure those rules are before any wordpress rules or any other kind of routing rules – Jon Lin Aug 14 '13 at 17:02