Welcome to WebmasterWorld Guest from 3.81.29.226

Forum Moderators: Ocean10000 & phranque

internal redirect takes down website

changing urls on blog posts

     
6:33 pm on Oct 28, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:June 4, 2002
posts: 1921
votes: 3


I redesigned a site that used to have everything in a WP blog (static pages and blog posts were in the root or redirected to the root). I took the static pages out of the blog and set up a separate WP blog for the posts and am currently 301ing the old blog posts to the new blog.

I had a discussion going in the Wordpress forum a few months back re how to download the database when the previous owner wouldn't give us access to the server - I managed to get the images but not the posts off the old server. However, I got some of the posts off Google, archive org, etc., and we are rewriting the others. I'm reposting the articles and trying to redirect the old URLs to the new ones.

The first internal redirect below worked fine but the 2nd one caused a 500 error. I even took out the "L" in the first one, but that didn't help.

Can anyone see what I did wrong?

RewriteRule ^nameofarticle1/$ https://example.com/blog/2019/10/25/nameofarticle1/ [R=301,L]
RewriteRule ^nameofarticle2/$ https://example.com/blog/2019/10/28/nameofarticle2/ [R=301,L]
7:36 pm on Oct 28, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3153
votes: 7


There's nothing wrong with that 2nd rule. Check your error log for the specifics of the error. Try retyping the directive in case there is an erroneous character in there somewhere?!

If that specific rule triggered a 500 error then it implies there is a syntax error with that directive and you would get that 500 error regardless of the requested URL. Is that the case? Otherwise, it might be triggering a conflict with another directive perhaps?

Btw, that's an "external redirect" (although I assume by "internal" you mean it's on the same host), not an "internal redirect" (which is the same as a "rewrite").

I even took out the "L" in the first one, but that didn't help.


External redirects should nearly always include the "L" flag. Removing the "L" flag would likely cause more problems.

This being WordPress, I assume these redirects are before the WordPress front-controller?
9:09 pm on Oct 28, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4558
votes: 363


This being WordPress, I assume these redirects are before the WordPress front-controller?
Also before your canonicalization rewrite (which should be between your redirects and the WP section).
11:02 pm on Oct 28, 2019 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11870
votes: 244


The first internal redirect below worked fine but the 2nd one caused a 500 error. I even took out the "L" in the first one, but that didn't help.

Can anyone see what I did wrong?

Check your error log for the specifics of the error.

^^^this^^^

not an "internal redirect"

"internal rewrite".
a redirect is a 3XX response.

before your canonicalization rewrite

that should be "hostname canonicalization redirect"
1:25 am on Oct 29, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15934
votes: 887


If that specific rule triggered a 500 error then it implies there is a syntax error with that directive and you would get that 500 error regardless of the requested URL.
It is possible to make a RewriteRule that only creates a 500 error if the requested URL is one that triggers the rule. (As always: 8,000 guesses how I know.) A useful difference is that a brings-down-the-whole-site 500 error leads to the generic Apache error page, while the URL-specific 500 error still permits display of your custom 500 page if you’ve got one, because the internal request for this page doesn’t trigger a fresh 500 error.

not an "internal redirect"
Sad but true: Apache itself uses this confusing locution to mean what we generally call a rewrite. (We won’t talk about their typical suggested Regular Expressions.) But that doesn’t mean we have to. Distinguishing between “internal rewrite” and “external redirect” is what is known in linguistics as Double Markedness (often a more useful term than “redundancy”).
6:08 pm on Oct 29, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:June 4, 2002
posts: 1921
votes: 3


@Penders

you said: Try retyping the directive in case there is an erroneous character in there somewhere?!

That gave me the idea of retyping the directive because I had copy/pasted it from the website URL to a word doc (to edit it) then copied that into htaccess and that is when the exact same type of URL wouldn't work. So some kind of extrenous character must have been included. I retyped it in htaccess and that worked, so I won't do that again.

Very simple problem/solution.

Thanks for everyone else that gave solutions. I'l add them to my htaccess bugs collection.
6:20 pm on Oct 29, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4558
votes: 363


I would add it to your "Reasons not to use MSWord for text editing" - it is not a plain text editor. I realize that it looks like text, but it snot. ;)
3:45 pm on Oct 30, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:June 4, 2002
posts: 1921
votes: 3


It wasn't MSWord. It was a small text editor - Tex-edit plus that I use all the time for text stuff. I just forgot I wasn't using bbedit.