Reputation: 11648
I want to redirect a path to a file as query parameter.
For ex:
http://subdomain.example.com/helloworld/
Should redirected to
/index.php?domainParam=subdomain¶m1=helloworld
I have tried multiple ways but they either helps with subdomain or with the path. But I want both of them to be redirected as a parameter in a query string.
Like:
RewriteCond %{HTTP_HOST} !^app\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ index.php?domainParam=%1 [L]
RewriteCond %{HTTP_HOST} !^app\.example\.com$ [NC]
RewriteRule ^([^/]+)/? index.php?source=$1 [L]
But it is not helping when redirecting both of them as parameters.
Need your assistance to merge them both.
Upvotes: 1
Views: 53
Reputation: 785128
You may use this rule for this task:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(?!app\.)([^.]+)\.example\.com$ [NC]
RewriteRule .* index.php?domainParam=%1¶m1=$0 [L,QSA]
Upvotes: 1