Just a question... can modrewrite redirect anything.domain.com to domain.com/anything (or domain.com/index.php?id=anything) without having to add all the sub domains? If so, do you have some sample expressions or tutorials on it? Thanks.
| SitePoint Sponsor |
Just a question... can modrewrite redirect anything.domain.com to domain.com/anything (or domain.com/index.php?id=anything) without having to add all the sub domains? If so, do you have some sample expressions or tutorials on it? Thanks.
- Nathan
The answer is yes.
>> anything.domain.com
>> to domain.com/anything
/.htaccess
>> anything.domain.comCode:RewriteEngine On RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC] RewriteCond %1 !^www$ [NC] RewriteRule ^$ /%1 [L]
>> to domain.com/index.php?id=anything
/.htaccess
Code:RewriteEngine On RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC] RewriteCond %1 !^www$ [NC] RewriteRule ^$ /index.php?id=%1 [L]
![]()
NICE! Thanks pippo, I was hoping you'd come across the thread!Thank very much.
Can I have a full URL in the last statement? Or does it have to be relative.
- Nathan
Hmm, I have:
And I go to test.artorg.co.uk and it says it cannot be resolved... any ideas why this is?RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.artorg\.co\.uk$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^$ /v3/member.php?id=%1 [L]
- Nathan
Bookmarks