Answers.Body: <p>I would not particularly advise creating a uri pattern that was just 'www.site.com/username' because usernames can essentially be anything which might cause routing conflicts (i.e. if the username is 'index' for example). You could however use something like 'www.site.com/members/username' or 'www.site.com/u/username'.</p>
  
  <p>One way to do this would be to add a route using a 'subpattern'. For more info check out the routing docs on <a href="http://buildwithcraft.com/docs/routing#accessing-subpatterns-in-your-templates">accessing subpatterns in your templates</a>.</p>
  
  <p>Here is the example given in the docs, which provides the variables 'year' and 'month' to the template that correspond to the matched uri segments (i.e.  `news/2015/02'):</p>
  
  <pre><code>'news/(?P&lt;year&gt;\d{4})/(?P&lt;month&gt;\d{2})' =&gt; 'news/_archive',
  </code></pre>
  
  <p>You could essentially do the same thing but with a 'username' variable.</p>
  
  <pre><code>'u/(?P&lt;username&gt;[^\/]+)' =&gt; '_thisTemplate',
  </code></pre>
  
  <p>You can then use the 'username' variable in your template to retrieve the corresponding user.</p>
  
  <pre><code>{% set user = craft.users.username(username).first() %}
  {% if user %}
      {{ user.firstName }}
      ...
  {% else %}
      {% redirect 404 %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-01T18:06:22.473Z
Answers.Text: Note that by ```{% set user %}``` you're overwriting Craft's global ```user``` variable (i.e. _the currently logged in user_). Not a problem in most cases, but probably worth mentioning.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-01T18:14:38.023Z
Answers.Text: @mmikkel Good point. Although, 'currentUser' would still refer correctly to the currently logged in user, which I believe is the recommended usage anyway.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-01T20:30:44.193Z
Answers.Text: To match everything but a slash for a URL pattern use this regular expression: `(?P<username>[^\/]+)`
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-01T21:37:21.597Z
Answers.Text: Thanks for the addition @carlcs. You also made me realize that I had an error in my expression, which was still expecting 4 digits. Corrected.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-02T08:08:36.813Z
Answers.Text: For the given example above, How would you construct the link? `<a href="{{ url('u/' ~ entry.author.username) }}">{{ entry.author.username }}</a>` is what I have, but with `404` redirection.  But anyway, some time ago I posted the question, if there would be possible to add a prefix to variable, like popular '#username'. In this case we wouldn't have to worry about any conflicts. Thanks to @Douglas McDonald, @mmikkel and @carlcs on participating this answer.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-02T16:38:02.833Z
Answers.Text: Yes. The link you posted in your comment looks correct. As for the extra character, the pound sign "#", as you probably know, is reserved for anchor tag links — so I would suggest using something else at a minimum, perhaps dash "-" or underscore "_". Although the best in my opinion is still a subpath such as "/u/username".
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-02T20:19:39.923Z
Answers.Text: Yes, a subpath is very good insurance. And I think, I leave it like that. Also I've voted to reopen [the question](http://craftcms.stackexchange.com/questions/9909/is-it-achievable-to-route-a-dynamic-uri-with-special-character) as it builds to this comment conversation.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-01T17:55:00.217Z
Answers.LastActivityDate: 2015-06-01T21:34:52.187Z
Answers.LastEditDate: 2015-06-01T21:34:52.187Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>So what I'd like is:</p>
  
  <p>If URI would look like {username}, load _thisTemplate.</p>
  
  <p>Couldn't find the way without solid point like author ID.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-01T12:53:47.623Z
Comments.Text: Had the same issue, had to work around like: `/people/phil-collins/832` ...
Comments.UserDisplayName: tom
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-01T15:31:38.633Z
Comments.Text: One of the options, yes. I doubt, that it is possible yet. The craft needs to know, what user is the click link to and without assigning an user's ID, I think it's impossible.
Comments.UserDisplayName: Dominik Krulak
Tags: <routing>
Title: Is it possible to route to www.site.com/username?
ThreadText: # Is it possible to route to www.site.com/username?
  
  (Asked by: username_0 on 2015-06-01)
  
  So what I'd like is:
  
  If URI would look like {username}, load \_thisTemplate.
  
  Couldn't find the way without solid point like author ID.
  
  **Tags:** routing
  
  > **Comments:**
  > **username_1**: Had the same issue, had to work around like: `/people/phil-collins/832` ...  
  > **username_0**: One of the options, yes. I doubt, that it is possible yet. The craft needs to know, what user is the click link to and without assigning an user's ID, I think it's impossible.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-06-01. Score: 10 | Accepted answer
  
  I would not particularly advise creating a uri pattern that was just 'www.site.com/username' because usernames can essentially be anything which might cause routing conflicts (i.e. if the username is 'index' for example). You could however use something like 'www.site.com/members/username' or 'www.site.com/u/username'.
  
  One way to do this would be to add a route using a 'subpattern'. For more info check out the routing docs on [accessing subpatterns in your templates](http://buildwithcraft.com/docs/routing#accessing-subpatterns-in-your-templates).
  
  Here is the example given in the docs, which provides the variables 'year' and 'month' to the template that correspond to the matched uri segments (i.e. `news/2015/02'):
  
  ```
  'news/(?P<year>\d{4})/(?P<month>\d{2})' => 'news/_archive',
  
  ```
  
  You could essentially do the same thing but with a 'username' variable.
  
  ```
  'u/(?P<username>[^\/]+)' => '_thisTemplate',
  
  ```
  
  You can then use the 'username' variable in your template to retrieve the corresponding user.
  
  ```
  {% set user = craft.users.username(username).first() %}
  {% if user %}
      {{ user.firstName }}
      ...
  {% else %}
      {% redirect 404 %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_3**: Note that by ```{% set user %}``` you're overwriting Craft's global ```user``` variable (i.e. _the currently logged in user_). Not a problem in most cases, but probably worth mentioning.  
  > **username_2**: @mmikkel Good point. Although, 'currentUser' would still refer correctly to the currently logged in user, which I believe is the recommended usage anyway.  
  > **username_4**: To match everything but a slash for a URL pattern use this regular expression: `(?P<username>[^\/]+)`  
  > **username_2**: Thanks for the addition @username_4. You also made me realize that I had an error in my expression, which was still expecting 4 digits. Corrected.  
  > **username_0**: For the given example above, How would you construct the link? `<a href="{{ url('u/' ~ entry.author.username) }}">{{ entry.author.username }}</a>` is what I have, but with `404` redirection.  But anyway, some time ago I posted the question, if there would be possible to add a prefix to variable, like popular '#username'. In this case we wouldn't have to worry about any conflicts. Thanks to @username_2, @mmikkel and @username_4 on participating this answer.  
  > **username_2**: Yes. The link you posted in your comment looks correct. As for the extra character, the pound sign "#", as you probably know, is reserved for anchor tag links — so I would suggest using something else at a minimum, perhaps dash "-" or underscore "_". Although the best in my opinion is still a subpath such as "/u/username".  
  > **username_0**: Yes, a subpath is very good insurance. And I think, I leave it like that. Also I've voted to reopen [the question](http://craftcms.stackexchange.com/questions/9909/is-it-achievable-to-route-a-dynamic-uri-with-special-character) as it builds to this comment conversation.  
  
  ---
  
  