Hi, all!
I'm trying to make mod_rewrite redirect from e.g. http://username.example.com/profile to http://example.com/user/username/profile.
But it redirect it to http://example.com/user/username/
And e.g http://username.example.com/?id=34&typ=4&zsfa=2 it redirects to http://example.com/user/username?id=34&typ=4&zsfa=2
.htacces:
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com [NC]
RewriteRule .* http://example.com/user/%1 [R=301,L]
mod_rewrite. subdomain redirecting
Moderator: General Moderators
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com [NC]
RewriteRule (.*) http://example.com/user/%1/profile/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com [NC]
RewriteRule (.*) http://example.com/user/%1/profile/$1 [R=301,L]
You don't understand me. /profile is just example. There maybe various casesmiro_igov wrote:RewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com [NC]
RewriteRule (.*) http://example.com/user/%1/profile/$1 [R=301,L]
http://username.example.com/profile/
http://username.example.com/news
http://username.example.com/?id=34&type=3, even this (serialized data in async's).
I need to glue everything after username.example.com/* to the end of example.com/user/username/*
2 miro_igov: thanks!
I corrected my code with yours a lil.
The correct is
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com/*$ [NC]
RewriteRule (.*) http://example.com/user/%1/$1 [R=301,L]
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
But, now if I delete [R=301,L] it wouldn't work.
What directive should I paste here for no redirecting but rewriting.
I mean if I entered
http://username.example.com/profile
it wouldn't redirect me, but understand this as
http://example.com/user/username/profile ?
I corrected my code with yours a lil.
The correct is
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com/*$ [NC]
RewriteRule (.*) http://example.com/user/%1/$1 [R=301,L]
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
But, now if I delete [R=301,L] it wouldn't work.
What directive should I paste here for no redirecting but rewriting.
I mean if I entered
http://username.example.com/profile
it wouldn't redirect me, but understand this as
http://example.com/user/username/profile ?