Get subdomain as a GET parameter

Basically I have this htaccess:

Options +FollowSymLinks
Options -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ([a-z0-9-]+).([a-z0-9-]+)([/admin])? [NC]
RewriteRule ^$ index.php?domainusr=%1 [L]

Imagine that the subdomain will be a User, and I want to get that user. But the thing is this htaccess will work, with some drawbacks:

My question is: How can I have this subdomain as a GET parameter in EVERY accessable content, without interfering with others GETs?

Upvotes: 1

Views: 345

Answers (1)

Croises
Croises

Reputation: 18671

If you want to add ?domainusr=%1 to all your links, with this .htaccess:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ([a-z0-9-]+)\.domain\.com [NC]
RewriteRule ^(.*)$ $1?domainusr=%1 [QSA,L]

Upvotes: 3

Related Questions