Answers.Body: <p>So from reading your updated answer and looking at the <a href="https://craftcms.stackexchange.com/questions/9986/is-it-possible-to-route-to-www-site-com-username/9992#9992">other question you mentioned</a> I would assume you are trying to create prefixed dynamic links that don't conflict with your routing.</p>
  
  <p>For example <code>site.com/about</code> would link to your about page and <code>site.com/#about</code> would load up your custom template.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>The problem with using a <code>#</code> for your trigger is that really this should be used for linking to internal sections on a page and with the above <code>site.com/#about</code> would actually just link to your index page and if you had a <code>&lt;div&gt;</code> with an id of <code>about</code> you'd find the scroll position at that div, so I think using a <code>#</code> is going to give you a lot of headaches.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Perhaps use the <code>@</code> sign? if it's good enough for twitter to use then I don't think you'll have many problems using it.</p>
  
  <p>So, in your <code>config/routes.php</code> you would have:</p>
  
  <pre><code>return array(
   '(?P&lt;username&gt;\@\w+)' =&gt; '_someCustomTemplate',
  );
  </code></pre>
  
  <p>This will match anything starting with an <code>@</code>, assign it to <code>username</code> a variable in your template and load it up, I tested on the Happy Lager install and it worked like a charm, <code>/about</code> goes to the about page <code>/@about</code> goes to my custom template</p>
  
  <p>So in your custom template you could have the following:</p>
  
  <pre><code>{# This will get rid of the @ #}
  {% set username = username|replace({'@': ''}) %}
  
  {% set user = craft.users.username(username) %}
  </code></pre>
  
  <p>If you want to change the trigger to something else, just change <code>@</code> in the route expression and then in the replace filter, but that should do the trick for you and avoid conflicts!</p>
  
  <p><em>on a side note, I replaced <code>@</code> with a <code>#</code> and it didn't work, just went to the home page</em></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-05T07:21:41.810Z
Answers.LastActivityDate: 2015-06-05T07:54:17.377Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Alec Ritson
Body: <p>The goal is to have a <strong>variable</strong>(link) merged with prefix "any special character", that will not break the URL(<em>this was pointed to my about character in URL lately, but in this question, We use "#")</em>. So the final output would be "site.com/#variable" (in my case it is the author of an entry and a link to author's profile. </p>
  
  <p>Also, I'd have to route it to get the correct template loaded. The whole reason behind is, that the current prefix would avoid of potential conflicts with other templates in case, some username will be 'index'.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-26T15:02:47.117Z
Comments.Text: "linkToLeft" is already different from "linkToRight"?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-26T15:07:30.387Z
Comments.Text: Understand this as "link" is variable and "ToLeft" and "ToRight" are two different links of type. Both serve different type of content. To you question, Yes it's already different.
Comments.UserDisplayName: Dominik Krulak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-26T15:49:06.040Z
Comments.Text: I'm not sure I'm following `"link" is variable and "ToLeft" and "ToRight" are two different links of type.`.  Maybe edit the original question with some further clarification?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-26T16:40:09.570Z
Comments.Text: Hope, the question's update will help.
Comments.UserDisplayName: Dominik Krulak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-26T17:20:13.527Z
Comments.Text: Where does the "toLeft" and "toRight" go in the final link? And I still don't get it, why do you want to prefix it with a "#"? They are already different!
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-26T17:35:02.270Z
Comments.Text: It doesn't matter where it goes. What matters is, what template gets loaded. The reason Why I defined the links with "ToLeft" and "ToRight" is, that both represent different types of content, which require two different templates. If I would want to set the route in CP for both links, It would looks like `*` loads "_ToLeft" and `*` loads "_ToRight" template. This would not work. So I think, the special character would actually help here.
Comments.UserDisplayName: Dominik Krulak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-27T11:52:07.800Z
Comments.Text: The _hashtag_ denotes a URL fragment and will essentially break your URL at the insertion point - as such, it's probably a poor choice of special character. More to the point, how are the two types of content different? Are they different entry types or the like? A decent way to solve this would be to point both URLs to the same, generic template, where you include the specific template based on the content - eg {% include entry.type ~ '-partial' %}
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-27T13:18:27.320Z
Comments.Text: Authors and entries. These are the content types.  Doing it this way, I wouldn't achieve a special character in the link. The question is unclear and I don't know How more precisely to clarify it for others, so I've proposed to close it.
Comments.UserDisplayName: Dominik Krulak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-27T15:05:15.997Z
Comments.Text: Is the idea that if you had two urls like `#author1linkToRight` and `#author1linkToLeft` you would be able to separate the `#author1` and `linkTo...` parts based on whether it has the special character prefix? So then you'd have two variables, `#author1` and `linkTo...` that you'd be able to use to pull the correct template in?
Comments.UserDisplayName: Alec Ritson
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-02T20:08:36.333Z
Comments.Text: Kind of not @Alec Ritson. I updated the question and it may link a little bit to [this question](http://craftcms.stackexchange.com/questions/9986/is-it-possible-to-route-to-www-site-com-username/9992#9992)
Comments.UserDisplayName: Dominik Krulak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-04T13:58:25.143Z
Comments.Text: If this gets reopened i'm 99% sure I have a solution...
Comments.UserDisplayName: Alec Ritson
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-05T06:24:32.013Z
Comments.Text: @AlecRitson Go for it :)
Comments.UserDisplayName: Lindsey D
Tags: <routes>
Title: Is it achievable to route a dynamic URI with prefixed character?
ThreadText: # Is it achievable to route a dynamic URI with prefixed character?
  
  (Asked by: username_0 on 2015-05-26)
  
  The goal is to have a **variable**(link) merged with prefix "any special character", that will not break the URL(*this was pointed to my about character in URL lately, but in this question, We use "#")*. So the final output would be "site.com/#variable" (in my case it is the author of an entry and a link to author's profile.
  
  Also, I'd have to route it to get the correct template loaded. The whole reason behind is, that the current prefix would avoid of potential conflicts with other templates in case, some username will be 'index'.
  
  **Tags:** routes
  
  > **Comments:**
  > **username_1**: "linkToLeft" is already different from "linkToRight"?  
  > **username_0**: Understand this as "link" is variable and "ToLeft" and "ToRight" are two different links of type. Both serve different type of content. To you question, Yes it's already different.  
  > **username_2**: I'm not sure I'm following `"link" is variable and "ToLeft" and "ToRight" are two different links of type.`.  Maybe edit the original question with some further clarification?  
  > **username_0**: Hope, the question's update will help.  
  > **username_1**: Where does the "toLeft" and "toRight" go in the final link? And I still don't get it, why do you want to prefix it with a "#"? They are already different!  
  > **username_0**: It doesn't matter where it goes. What matters is, what template gets loaded. The reason Why I defined the links with "ToLeft" and "ToRight" is, that both represent different types of content, which require two different templates. If I would want to set the route in CP for both links, It would looks like `*` loads "_ToLeft" and `*` loads "_ToRight" template. This would not work. So I think, the special character would actually help here.  
  > **username_3**: The _hashtag_ denotes a URL fragment and will essentially break your URL at the insertion point - as such, it's probably a poor choice of special character. More to the point, how are the two types of content different? Are they different entry types or the like? A decent way to solve this would be to point both URLs to the same, generic template, where you include the specific template based on the content - eg {% include entry.type ~ '-partial' %}  
  > **username_0**: Authors and entries. These are the content types.  Doing it this way, I wouldn't achieve a special character in the link. The question is unclear and I don't know How more precisely to clarify it for others, so I've proposed to close it.  
  > **username_4**: Is the idea that if you had two urls like `#author1linkToRight` and `#author1linkToLeft` you would be able to separate the `#author1` and `linkTo...` parts based on whether it has the special character prefix? So then you'd have two variables, `#author1` and `linkTo...` that you'd be able to use to pull the correct template in?  
  > **username_0**: Kind of not @username_4. I updated the question and it may link a little bit to [this question](http://craftcms.stackexchange.com/questions/9986/is-it-possible-to-route-to-www-site-com-username/9992#9992)  
  > **username_4**: If this gets reopened i'm 99% sure I have a solution...  
  > **username_5**: @username_4 Go for it :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_4 on 2015-06-05. Score: 4 | Accepted answer
  
  So from reading your updated answer and looking at the [other question you mentioned](https://craftcms.stackexchange.com/questions/9986/is-it-possible-to-route-to-www-site-com-username/9992#9992) I would assume you are trying to create prefixed dynamic links that don't conflict with your routing.
  
  For example `site.com/about` would link to your about page and `site.com/#about` would load up your custom template.
  
  **Problem**
  
  The problem with using a `#` for your trigger is that really this should be used for linking to internal sections on a page and with the above `site.com/#about` would actually just link to your index page and if you had a `<div>` with an id of `about` you'd find the scroll position at that div, so I think using a `#` is going to give you a lot of headaches.
  
  **Solution**
  
  Perhaps use the `@` sign? if it's good enough for twitter to use then I don't think you'll have many problems using it.
  
  So, in your `config/routes.php` you would have:
  
  ```
  return array(
   '(?P<username>\@\w+)' => '_someCustomTemplate',
  );
  
  ```
  
  This will match anything starting with an `@`, assign it to `username` a variable in your template and load it up, I tested on the Happy Lager install and it worked like a charm, `/about` goes to the about page `/@about` goes to my custom template
  
  So in your custom template you could have the following:
  
  ```
  {# This will get rid of the @ #}
  {% set username = username|replace({'@': ''}) %}
  
  {% set user = craft.users.username(username) %}
  
  ```
  
  If you want to change the trigger to something else, just change `@` in the route expression and then in the replace filter, but that should do the trick for you and avoid conflicts!
  
  *on a side note, I replaced `@` with a `#` and it didn't work, just went to the home page*
  
  
  ---
  
  