I want to redirect all subdomains to the user profile , eg:

redirect this URL : http://alexusername.example.com

To : http://alexusername.example.com

But showing the content of : http://example.com/user.php?q=alexusername

I mean that I want to show the content of the http://example.com/user.php?q=alexusername without changing the URL in the browser I want it to still http://alexusername.example.com

I have tried this :

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} !www.blackhawk.site$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).blackhawk.site [NC]
RewriteRule ^(.*)$ http://blackhawk.site/user.php?q=%2 [L]
  • 2
    You don't use rewrite here, you need to make a virtual host that maps the subdomain to the script. – Tero Kilkanen Mar 14 '17 at 2:00
  • How to do that please ? – Black Hawk Mar 14 '17 at 12:08
  • Google for "apache virtual host setup" and follow guide. – Tero Kilkanen Mar 14 '17 at 12:47
  • I think this require some Apache permissions but I have a domain on a hosting server ! – Black Hawk Mar 14 '17 at 15:02
  • 2
    Then you need to set up hosting yourself on a place where you can modify Apache configuration. – Tero Kilkanen Mar 14 '17 at 19:56

Your Answer

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

Browse other questions tagged or ask your own question.