How to get SeoRedirection to work

Mar 24, 2011 at 1:12 PM
Edited Oct 24, 2011 at 8:10 PM

Did what

http://geekiest.net/post/Search-Engine-Optimization-Redirecting-Old-URLs-to-New-URLs-permanently-with-Http-Status-Code-301-BlogEngineNet.aspx

 

Said to do. Extension works, but does not redirect.  Anyone else using this?  If so how long does it take to start redirecting?

Java Blog

Apr 1, 2011 at 6:14 PM

Hello, 

i'm experiencing the same behavior. I've also posted the issue to that site you've mentioned http://geekiest.net/post/Search-Engine-Optimization-Redirecting-Old-URLs-to-New-URLs-permanently-with-Http-Status-Code-301-BlogEngineNet.aspx and hope someone smarter will figure it out (i took a look at the code but... no ideas).

Would be very appreciated if someone got a workaround to post it here: its really a must-have !

Thanks in advance

fb

Apr 1, 2011 at 7:36 PM

hello everyone,

Seoredirection is very simple, if you have read the post which you mentioned in your comment.

And it start working instantly with out any delay.

 

If it is not working even after enabling the SEO extension then you need to check two things:

1. Make sure you have paste old url and new url properly and after adding they must be appear in the SEO url list on the extension page.

2. Make sure you have added the below line in your web.config file under httpmodule.

<add name="SeoRedirector" type="SeoRedirector, App_Code"/>

 

Let me know if problem still persist.

Thanks,

Jitendra

Apr 1, 2011 at 8:29 PM
I know i must sound a little dumb ..
but i've triple checked everything ...
tomorrow i'll check again and if it still persists i'll make a video and an extract of the conf files.

Thank you very much for your consideration
fb

2011/4/1 jitendraapi <notifications@codeplex.com>

From: jitendraapi

hello everyone,

Seoredirection is very simple, if you have read the post which you mentioned in your comment.

And it start working instantly with out any delay.

If it is not working even after enabling the SEO extension then you need to check two things:

1. Make sure you have paste old url and new url properly and after adding they must be appear in the SEO url list on the extension page.

2. Make sure you have added the below line in your web.config file under httpmodule.

<add name="SeoRedirector" type="SeoRedirector, App_Code"/>

Let me know if problem still persist.

Thanks,

Jitendra

Read the full discussion online.

To add a post to this discussion, reply to this email (blogengine@discussions.codeplex.com)

To start a new discussion for this project, email blogengine@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com




--
Federico Bessone
Responsabile Tecnico e Amministrativo
BLC - Benessere Lavoro Correlato

web: www.benesserelavorocorrelato.it - www.stressometro.it
mail: f.bessone@benesserelavorocorrelato.it
canale youtube: www.youtube.com/blcitalia

Cellulare: 335 13 87 256
Apr 2, 2011 at 12:46 PM

Still same problem here.

 

Tried everything new still not redirecting.

Here are the files I am using:

 

<httpModules>
      <add name="SeoRedirector" type="SeoRedirector, App_Code"/>
      <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core" />
      <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core" />
      <add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core" />
      <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core" />
      <!--Remove the default ASP.NET modules we don't need-->
      <remove name="PassportAuthentication" />
      <remove name="Profile" />
      <remove name="AnonymousIdentification" />
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
    </httpModules>

_____________________________________________________________________________________________________________________________________________________

 

using System;
using System.Data;
using System.Web;
using BlogEngine.Core.Web.Controls;
using BlogEngine.Core.Web.Extensions;

[Extension("SEO Redirection Urls", "1.0", "<a href=\"http://www.spicelogic.com\">SpiceLogic Inc.</a>")]
public class SeoRedirection
{
    static protected ExtensionSettings _settings;

    public SeoRedirection()
    {
        ExtensionSettings settings = new ExtensionSettings("SeoRedirection");
        settings.AddParameter("OldUrl", "Old Url", 255, true, true, ParameterType.String);
        settings.AddParameter("NewUrl", "New Url", 255, true, false, ParameterType.String);

        // describe specific rules for entering parameters
        settings.Help = "Redirects an Old Url to New Url with Http Status Code 301";
        //------------------------------------------------------
        ExtensionManager.ImportSettings(settings);
        _settings = ExtensionManager.GetSettings("SeoRedirection");
    }
}

public class SeoRedirector : IHttpModule
{
    public void Dispose()
    {
    }

    public void Init(HttpApplication context)
    {
        context.BeginRequest += context_BeginRequest;
    }

    private static void context_BeginRequest(object sender, EventArgs e)
    {
        HttpContext context = ((HttpApplication)sender).Context;
        ExtensionSettings seoRedirectorSettings = ExtensionManager.GetSettings("SeoRedirection");
      
        if(seoRedirectorSettings != null)
        {
            DataTable table = seoRedirectorSettings.GetDataTable();
            string newUrl = null;
            foreach(DataRow row in table.Rows)
            {
                if(row["OldUrl"].ToString().Equals(context.Request.Url.AbsoluteUri, StringComparison.OrdinalIgnoreCase))
                {
                    newUrl = row["NewUrl"].ToString();
                    break;
                }
            }

            if(newUrl != null)
            {
                context.Response.StatusCode = 301;
                context.Response.Status = "301 Moved Permanently";
                context.Response.AddHeader("Location", newUrl);
            }
        }
 
    }
}

 

jitendraapi  did you tried it on a live server yet?  I saw in your post example its local not on a server.

 

http://www.blogenginewall.com/post/2011/04/01/BlogEngine-SEO-Permanent-Redirection-From-Old-URL-To-New-URL.aspx

 

Apr 2, 2011 at 12:54 PM

Here are some screen shots:

http://awesomescreenshot.com/058ao5o35

http://awesomescreenshot.com/032ao5l55

 

http://awesomescreenshot.com/03aao5p7a

 

Apr 2, 2011 at 2:17 PM

The reason I wanted this redirect is because I keep getting these 404 errors in my ELAMH log file:

 

http://awesomescreenshot.com/0d2ao9197

Apr 3, 2011 at 1:33 AM

Yes, Brian,

It seems it is not working on live server. Let me check.

Apr 3, 2011 at 3:03 AM

Ok, I got the issue.

Http modules are defined at two places in latest blogengine.net config file. So to make it work add the following line of code in web.config file under <httpModules> and <modules>.

<add name="SeoRedirector" type="SeoRedirector, App_Code"/> 

For more details read my post - "BlogEngine SEO Permanent Redirection From Old URL To New URL"

I have changed it and mentioned both changes.

Also i have tweaked "SeoRedirection.cs" for improved redirection you can take a get latest of this file as well. But it is not necessary to make it work. Just make the above changes in web.config file and it will work.

Let me know if you need any other information.

Thanks,

Jitendra

Apr 3, 2011 at 6:16 AM

Tried both  web.config and new SeoRedirection.cs"   still same problem

Apr 3, 2011 at 6:35 AM

Restarted the server by re uploading the core.dll file.  Still does not work.

 

Getting no errors

Apr 3, 2011 at 7:25 AM

Not sure why it is not working at your end.

I have checked its working fine at local and on live server. Check out the following URL:

 

Old URL - http://staging.blogenginewall.com/post/2010/10/08/Analysts-Predict-Tough-Holiday-Season.aspx

New URL - http://staging.blogenginewall.com/post/2010/10/08/Analysts-Predict-Tough-Holiday-Season-2.aspx

 

It might be possible that SEORedirector module is not even active on your site. Do one thing, download the following sample webpage and copy it to your server and browse it. And then check it is listing SeoRedirector along with other HTTPModules or not.

download:- http://staging.blogenginewall.com/file.axd?file=2011%2f4%2fdefault.zip

Apr 3, 2011 at 8:47 AM

http://www.kbdavis07.bloggersonline.com/default/default2.aspx

 

System.Web.Caching.OutputCacheModule
System.Web.SessionState.SessionStateModule
System.Web.Security.WindowsAuthenticationModule
System.Web.Security.FormsAuthenticationModule
System.Web.Security.DefaultAuthenticationModule
System.Web.Security.RoleManagerModule
System.Web.Security.UrlAuthorizationModule
System.Web.Security.FileAuthorizationModule
System.Web.Security.AnonymousIdentificationModule
System.Web.Profile.ProfileModule
System.Web.UrlMappingsModule
BlogEngine.Core.Web.HttpModules.WwwSubDomainModule
BlogEngine.Core.Web.HttpModules.UrlRewrite
BlogEngine.Core.Web.HttpModules.CompressionModule
BlogEngine.Core.Web.HttpModules.ReferrerModule
System.Web.Handlers.ScriptModule
Elmah.ErrorLogModule
SeoRedirector

Apr 3, 2011 at 9:01 AM

Had to delete it from server causing problems with default page :)

Apr 3, 2011 at 9:03 AM

Can you paste the old and new URLs.

Apr 3, 2011 at 9:15 AM

 

www.kbdavis07.bloggersonline.com/post/feed/2011/03/25/Contact.aspx

 

 

www.kbdavis07.bloggersonline.com/Contact.aspx

 

 

ScreenShot: http://www.diigo.com/item/image/17qct/d9ou

Apr 3, 2011 at 9:30 AM

Got an issue :)

Use complete URL while adding in seo extension :) So include "http://" before the OLD and NEW Url and let me know if it works ?

Apr 3, 2011 at 12:18 PM


 

Must use http://  in the url for both sides!!!!

 

Works great now!!

 

Thanks again jitendraapi

 

You are the man!!

Apr 3, 2011 at 12:47 PM

Next thing to do now is  make SeoRedirection  a page within the admin panel.

 

Like this: http://awesomescreenshot.com/0ebaptsf0

 

Also a way to import bulk lists of urls to redirect to for instead of manually inputing them.

Apr 3, 2011 at 12:58 PM
Edited Apr 3, 2011 at 1:32 PM

Got a work around to get this done:

http://awesomescreenshot.com/074apu600

 

Using the redirect   have the Old URL: /admin/Seo.aspx

New URL:  /admin/Extension%20Manager/default.aspx?ctrl=params&ext=SeoRedirection

 

Also put this in your web.sitemap  file:

 

<siteMapNode url="~/admin/Seo.aspx" title="SEO" description="" roles="AccessAdminPages" />

 

This puts it in the admin menu alot easier to get to other than going to Extensions ---> Edit 

Apr 4, 2011 at 4:30 AM

I am glad that my tips worked.

You are always welcome :)

Apr 4, 2011 at 4:40 AM

Now next project:  A way to import bulk lists of urls to redirect to for instead of manually inputing them.   :)

 

 

But for now I am working on blocking spam spiders that keeps crawling my website.

 

Scanning for links that for sure does not exist:

 

'/post/feed/2010/12/28/Contact.aspx'

'/post/2010/10/08/Contact.aspx

 

User-Agent: Baiduspider+(+http://www.baidu.com/search/spider.htm)

 

Screenshot of ELMAH Log:

 

http://awesomescreenshot.com/0dfar3r00

 


Apr 4, 2011 at 4:48 AM

Good Keep it up digging BE more and more :)

Apr 4, 2011 at 4:50 AM

Yep :)

Apr 4, 2011 at 8:44 AM

Wow :) two vacation days for me and two of hard work for you :)

I recreated everything (web.config, extension cs file etc) as per last suggestions (put in <modules>, use http:// etc) and now it works.

Thank you very much !

fb

Apr 4, 2011 at 6:39 PM

Thanks @fbessone

I am sure you must have a nice weekend :)