Forum Moderators: phranque
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{QUERY_STRING} ^mv=[0-4]$
RewriteRule ^([A-Za-z0-9]+)$ [$1.example.com...] [L,R]
But this doesnt work for the [example.com...]
What if you simply remove the QUERY_STRING line from the above ruleset? This should then redirect "https://example.com/firstnamelastname", as well as "https://example.com/firstnamelastname?mv=0", "https://example.com/firstnamelastname?mv=1", etc. (?)
However I cannot get these to redirect [example.com...]
Is that the entire requested URL? No trailing slash, no other content?
Also: does "these" mean the rule quoted immediately above, or does it mean all rules? The last listed rule-- the one that's currently missing the "=301" part-- needs to come before the www. redirect.
The whole mv=[0-4] business is a red herring. By default, any redirect will quietly reappend the query string, if any, without changing it. If instead you want all query strings to go away, simply add
?
to the end of the target. There is no need for a separate rule.
the last 3 rules are there to redirect urls that are
[example.com...] to 4
Which is working. However I am still getting 404 errors on
[example.com...]
no trailing slash
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{QUERY_STRING} ^mv=[0-4]$
RewriteRule ^([A-Za-z0-9]+)$ [$1.example.com...] [L,R]
However I cannot get these to redirect [example.com...]
If i remove the Query string from the last 3 lines then If i would click on features link on my website It would redirect to [features.example.com...] which is what the rules at the top are preventing.
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond $1 !^features$
RewriteRule ^([A-Za-z0-9]+)$ [$1.example.com...] [L,R]