redirecting old site pages to single page on dnn portal

只谈情不闲聊 提交于 2019-12-11 19:19:41

问题


We are using Community Edition of DNN. There is old site with bunch of html, aspx pages that should (not all of them though) redirect to single (default) page in new DNN portal v7.1 (301 redirect). Here is an example:

  • www.mysite.com/hello.html -> www.mysite.com
  • www.mysite.com/mypath/hello.html -> same as above
  • the same with.aspx pages -> same as above
  • www.mysite.com/mypath -> same as above

Is it possible to implement the goal using features of DNN CE or ASP.NET itself? So far only two things are coming on top of my head:

  1. httpRedirect in web.config - but that will only cover .html part, and only because new site is not using any files like that

  2. friendly urls (making chages to siteulrs.config) - works for any scenarios in question but though after redirect customer is landed on home page, browser's url bar keeps showing old url (and I'm not sure how good is that from 301 SEO perspective)

Thanks!


回答1:


I can't think of how to do this in DNN, but you could use IIS URL Rewrite

Using URL Rewrite, you can define all sort of rules, via IIS, that will tell IIS when to Redirect a request. You can use Regular Expressions or Wildcards to define the rules, which get written into the web.config.

Something like:

Rule 1: Request to www.mysite.com/hello.html -> Redirect to www.mysite.com
Rule 2: Request to www.mysite.com/mypath/* -> Redirect to www.mysite.com/{0}



回答2:


write the following code in your skin file.

<script type="text/javascript">
    function pageRedirect() {
        window.location.replace("Your_URL");
    }      
    setTimeout("pageRedirect()", 1000);
</script>



回答3:


I can't think of better solution than the one specified above. After installing URL Rewrite from Microsoft site, we were able to edit web.config of the portal (you can do that manually or via interface under inetmgr snap-in:

    <rewrite>
        <rules>
            <rule name="My Rule No 1" patternSyntax="Wildcard" stopProcessing="true">
                <match url="*helloworld*" />
                <action type="Redirect" url="/" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>

The section above must be added under system.webServer of web.config.



来源:https://stackoverflow.com/questions/22706427/redirecting-old-site-pages-to-single-page-on-dnn-portal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!