Reputation: 1948
I want to allow the users to type
xyz.example.com
in order to reach
test.php?id=xyz
What code should I use to accomplish my goal?
Upvotes: 0
Views: 154
Reputation: 9509
Try adding the following to your htaccess file in the root directory of your example.com domain
RewriteEngine on
RewriteBase /
#if the host is anything.example.com
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
#send all requests to test.php
RewriteRule .* test.php?id=%1 [L]
Upvotes: 1