Directing subdomain to main domain and keeping the subdomain format with .htaccess

Question

I am using bluehost and a single site wordpress site.

I want when someone types in bob.example.com to show the WordPress site at example.com, but still use the subdomain address (bob.example.com). I have a piece of PHP in WordPress that recognizes the subdomain and delivers contact information based on that.

I have tried using this RewriteRule in my .htaccess file and while I feel a step closer, it is just giving new errors:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*).example.com$
RewriteRule ^(.*)$ http://example.com [P]

When using wildcard redirects through bluehost, I get Bad Request and an additional 400 Bad Request error when trying to find the errordocument

Without using wildcard redirects, it does not seem to get to the point where the browser utilizes the .htaccess file in my example.com directory.

What do I need to put into my .htaccess file to get this to work how I want it to?

0
, , Lisa 12 months 0 Answers 65 views 0

Leave an answer