-1

I am looking to create a .htaccess file on my website to allow me enter "username.domain.com" as the url and it redirects me to "http://domain.com/index.php?a=profile&u=username"

eg: "john.domain.com" redirects to "http://domain.com/index.php?a=profile&u=john"

Thanks

oluday
  • 3
  • 4
  • Possible duplicate of [Create Subdomains on the fly with .htaccess (PHP)](http://stackoverflow.com/questions/586129/create-subdomains-on-the-fly-with-htaccess-php) – Josh Rumbut Jun 17 '16 at 23:37

1 Answers1

0

This would not go into .htaccess, it would go into you httpd.conf file. Look into this question: VirtualHost with wildcard VirtualDocumentRoot

You would also need to setup a wildcard dns record for *.example.com to point to your server. In PHP you would have something like this as the index.php file for your wildcard.

<?php
    $domain = "test.example.com";
    $domain_parts = explode(".", $domain);
    $username = $domain_parts[0];
    header("location: http://example.com/".$username);
?>
Community
  • 1
  • 1
Gary Mathis
  • 171
  • 1
  • 4