سؤال

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!

هل كانت مفيدة؟

المحلول

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}

نصائح أخرى

write the following code in your skin file.

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

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top