Reputation: 65
I would like to redirect varying subdomains with a htaccess file. An example:
URL: http://varying-string.example.com/
redirect.php: <?php echo $_GET['value']; ?>
Output: varying-string
This is my try, but i doesnt work.
.htaccess
RewriteRule ^.*\.redirect.episch.ch$ redirect.episch.ch/redirect.php?value=$1
Upvotes: 0
Views: 451
Reputation: 16117
You can use the RewriteCondition
to catch the subdomain pattern.
The patterns you catch in rewrite conditions need to be referred as %1
in the rewrite rule.
RewriteCond %{HTTP_HOST} (\w*).domain.com [NC]
RewriteRule domain.com /redirect.php?value=%1 [L,R=301]
Upvotes: 1