0

I am trying to have a URL that would look like:

mysite.com/@username

Which would route to something like:

subdomain.mysite.com/user/@username

I'm terrible with RewriteRules and have been struggling to try to get this to work. Some of the things I have tried are:

RewriteRule subdomain.mysite.com/user/(.*) mysite.com/$1  [R=302,NC,L]

RewriteRule ^(.@)(.*) subdomain.mysite.com/user/$1  [R=302,NC]

RewriteRule ^(.@)([A-Za-z0-9_]+) mysite.com/user/$1  [R=302,NC]

I realize those probably make absolutely no sense. Every time I try to get my head around how the routing works, I get turned around and start writing crap like you see above.

Any pointers would be appreciated. Thanks.

Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133

1 Answers1

1

You can't route to a subdomain (using htaccess anyway) but you can redirect there.

RewriteEngine On
RewriteBase /
RewriteRule @(.*) http://subdomain.mysite.com/user/@$1 [L,R=301]

The @ symbol should be okay https://stackoverflow.com/a/1547940/763468

Community
  • 1
  • 1
Steve Robbins
  • 13,672
  • 12
  • 76
  • 124
  • Great! I had actually just figured out an alternative way of doing it that was working, but I like yours better: ([@A-Za-z0-9_]+) http://subdomain.mysite.com/user/$1 [R=302,NC,L] – Jeremy Harris Jun 13 '12 at 18:41