我可以更改内容的 URL 吗? [英] Can I change URL of content?

查看:37
本文介绍了我可以更改内容的 URL 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一些内容.我注意到内容的 URL 是根据内容名称自动生成的.如果我可以编辑网址或输入自定义网址,请指导我吗?

I have created some contents. I have noticed URL of content is generated automatically based on name of content. Can you please guide me if I can edit URL or enter a custom URL ?

谢谢

推荐答案

您可以通过 2 种方式做到:

You can do it in 2 ways:

1

在 umbraco 网站根目录的/config 文件夹中的 UrlRewrite.config 中设置这些规则.添加新规则:

Setup these rules in UrlRewrite.config in /config folder in your umbraco websites root. To add new rule:

<add name="produktidrewrite" 
    virtualUrl="^~/product/(.*).aspx" 
    rewriteUrlParameter="ExcludeFromClientQueryString" 
    destinationUrl="~/product.aspx?productid=$1" 
    ignoreCase="true" />

2.

或者您可以在代码中添加自定义路由.创建一个从 Umbraco.Core.ApplicationEventHandler 继承的新类.然后覆盖 ApplicationStarted 以添加您的规则.像这样:

Or you can add a custom route in your code. Create a new class which inherit from Umbraco.Core.ApplicationEventHandler. Then overwrite ApplicationStarted to add your rules. Like this:

protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
    //Custom route
    RouteTable.Routes.MapRoute(
    "SomeName",
    "Something/{action}/{id}",
    new
    {
        controller = "MyController",
        action = "Index",
        id = UrlParameter.Optional
    });
}

这篇关于我可以更改内容的 URL 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆