MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

vanity urls  (Mono Support )

Viewed 26487 time(s), 7 post(s) 5/17/2011 10:16:07 PMby ldc0618
ldc0618

ldc0618

5/17/2011 10:16:07 PM
Is it possible to configure vanity urls for groups and users

for example:
http://localhost:8083/MonoX/Pages/SocialNetworking/Groups/GroupView/ogTE0Fmv1E6yrZ2lAYWbkg/Web-design/

would become:
http://localhost:8083/Web-design/

Thanks
This content has not been rated yet. 
20 Reputation 5 Total posts
khorvat

khorvat

5/18/2011 7:30:32 AM
Hi,

you may notice that (http://localhost:8083/MonoX/Pages/SocialNetworking/Groups/GroupView/ogTE0Fmv1E6yrZ2lAYWbkg/Web-design/) this is already a rewritten URL but if you want to make this even shorter you can do this by using the standard MonoX rewriting mechanism.  You can find more information related to MonoX URL rewriting in MonoX manual under the "2.5.1.1 URL rewriting". Here is a sample how this would look like:

<rewrite url="^(.*)/Web-design/(\?(.+))?$" to="$1/MonoX/Pages/SocialNetworking/Groups/GroupView/ogTE0Fmv1E6yrZ2lAYWbkg/Web-design/$2" name="WebDesign" defaultPage="/MonoX/Pages/SocialNetworking/Groups/GroupView/ogTE0Fmv1E6yrZ2lAYWbkg/Web-design/" urlPattern="/MonoX/Pages/SocialNetworking/Groups/GroupView/ogTE0Fmv1E6yrZ2lAYWbkg/Web-design/" />

Note: You need to add the above rewriting rule to the web.config

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
ldc0618

ldc0618

5/18/2011 1:43:38 PM
Thanks but what if i have ten of thousands of groups? I am considering migrating an existing community site to monox and this is a critical consideration for me. Is there a more generic rule or another approach?
This content has not been rated yet. 
20 Reputation 5 Total posts
denis

denis

5/18/2011 8:03:25 PM
A more universal approach would require the presence of the groups' unique ID (a shortened Guid, like "ogTE0Fmv1E6yrZ2lAYWbkg" in the example above). MonoX by default does not require users to use unique group names when opening a group.
You can change this behaviour by changing the group-related URL rewriting rules, enforcing the name uniqueness in the group creation part (GroupEdit.ascx), and manually setting the GroupId property in the group view part (GroupView.ascx). This task requires a bit of coding, I we can send a code skeleton if you are interested.
This content has not been rated yet. 
7207 Reputation 956 Total posts
ldc0618

ldc0618

5/18/2011 8:10:34 PM
That would be great if you could send as I am just getting started
This content has not been rated yet. 
20 Reputation 5 Total posts
denis

denis

5/20/2011 10:40:56 PM
OK, I am preparing a small example that uses a simpler approach - using the custom URL rewriter transform method. It allows users to enter arbitrary URL formats that are transformed on the fly to the required set of parameters. In your case, group name will be transformed to the group id that is needed by all group modules, although that ID will not be visible in the URL.
Note that it is still recommended to have one additional level in your URL to identify the rewriting section. For example, instead of http://localhost:8083/Web-design/ you will need (in almost real world scenarios) to have http://localhost:8083/Group/Web-design/ . "Group" can be any string of your choice, but without it, basically every resource will be mapped to group section.



This content has not been rated yet. 
7207 Reputation 956 Total posts
denis

denis

5/23/2011 8:07:58 PM
As promised, I have put together a small blog post with a code sample that can be used in such scenarios: http://www.mono-software.com/Blog/post/Mono/110/Customizing-ASP-NET-URL-rewriting-rules/
This content has not been rated yet. 
7207 Reputation 956 Total posts