Can anyone tell me how to do the following using mod rewrite? I want to take any URL request containing "www.domainname.com" or "domainname.com" and replace "www.domainname.com" or "domainname.com" with "ip_address/~username". All the stuff in the URL before and after the replacement should remain intact. Thanks!
#Redirect domain/www.domain to you're ip RewriteCond %{HTTP_HOST} ^domainname.com RewriteRule ^(.*)$ http://ipaddress/~user/$1 [r=301,L] My regex is rusty, but this works on on of our sites.. Others, feel free to correct me. Above code will only work for domainname.com and not www, you can either add another one with www, or use a better regex.
Your code looks right. I would have left out the RewriteCond, though, and just done: RewriteEngine On RewriteRule www.domain.com/(.*) http://ipaddress/~user/$1 [r=301,L] RewriteRule domain.com/(.*) http://ipaddress/~user/$1 [r=301,L] Code (markup):