7

I'm migrating the content of a Wordpress blog to EE. The old blog has this URL structure:

/news/2012/08/08/2013-schedule/

And I need to redirect to this:

/news/post/2013-schedule/

At the moment I am using this .htaccess redirect:

RedirectMatch 301 /news/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /news/post/$4

But it's resulting in this URL:

/news/post/2013-schedule/?/news/2012/08/08/2013-schedule/

This is not the end of the world, because I get the right results, despite the extra URL segments, but I'd really rather they went away.

Any help?

FWIW, I'm using the EllisLab-approved redirect method for removing index.php.

8
  • You'll probably need to post all your rewrite rules because the order can be important. On a separate note, have you thought about leaving the URLs as they are and getting EE to work with the date structure, because even if you do 301 redirects, you're going to see negative SEO results. – Tyssen Nov 29 '12 at 22:13
  • @Tyssen can you elaborate on the "negative SEO results" if you redirect URL's with a 301 redirect? I've been doing this for years and have never had issues. I would love to know if I am missing something. – Paulo Elias Nov 29 '12 at 22:35
  • @Tyssen I'd also love any info you have on the SEO effects this may have. In any case, changing the URL struction wouldn't help, as there are other sections of the site that need to be re-mapped as well. – Tim Nov 29 '12 at 22:57
  • I will try to play with the order of my redirects, thanks for the thought. – Tim Nov 29 '12 at 22:57
  • 301 redirects tell Google that the page has moved from one location to another and in reality Google should just transfer all the link juice to the new location, but in reality, some of it gets lost on the way, particularly when you're changing the URLs of a lot of pages at the same time. So if you were to start afresh with a completely new URL structure, even with careful 301 redirects in place, you'd probably still see a drop off in search rankings. thatsit.com.au/seo/reports/myth/… has a bit more info. – Tyssen Nov 30 '12 at 2:24
3

Few things I'd try first:

  1. Have you tried adding the ? to the approved method after index.php?
  2. If that doesn't work, have you tried adding ? before /news/post/$4 to see if that changes anything?
  3. Check your $config['uri_protocol'] or add it to your config and change from AUTO to one of the other settings (check http://devot-ee.com/ee-config-vars to see the different options)

Any of that help?

Edit: I think this is related to an issue I had which was outlined here, hence Option 3: http://ellislab.com/forums/viewthread/202909/#957589

1
  • 1
    Thank for the thoughts — 1. This is already in place. 2. Server error. 3. No visible effect. – Tim Nov 29 '12 at 21:29
2

I think your rule is being evaluated at least twice and returns a match twice, once before and once after you do your index.php hiding.

You must be more narrow about what you are matching on. I think this will do the trick:

RedirectMatch 301 ^index.php/news/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /news/post/$4 [L]
0

This is not marked as answered, did you find a solution? I don't know off the top of my head why this would be happening, but one thing to try would be to put an absolute url instead of a relative one at the destination of your redirectMatch statement. The docs ask for the full URL.

Try replacing that last (.*) with (([\/\w \.-]*) if a query string is somehow being added internally before reaching that step, that should strip it out by matching only numbers letters underscores dots and hyphens.

You may also want to move that up earlier in your list of redirects, it seems likely that you are getting unexpected input into your redirect. You could turn on redirect logging in Apache to try to get a better sense of what is happening.

2
  • It's a good thought, but I'm already redirecting to the full URL. – Tim Dec 4 '12 at 16:10
  • I guess a simpler segment than the one I edited into my answer there would be ([^\?]*) (not totally sure if the escape is needed on the question mark there or not) – UltraBob Dec 4 '12 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.