03-04-2008, 01:30 PM
|
#5 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Since we're afforded the yumminess that is regular expressions, we can simply specify that the trailing slash is optional with the question mark character (?). Also, will the varying values only ever be numbers? Or, would you like to only capture what's between sample/ and the next forward slash (if there is one)? I'm just asking because it's better to make the matching expression as specific as possible! At the moment sample/my/sub/domain.html would try to redirect to http://my/sub/domain.html.domain.com which I'm fairly sure you don't want.
Anyhow, to answer your question:
RewriteRule ^sample/(.*)/? http://$1.domain.com [R=301,L]
|
|
|
|