Forum Moderators: phranque

Message Too Old, No Replies

internal redirect takes down website

changing urls on blog posts

         

Lorel

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

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



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]

penders

7:36 pm on Oct 28, 2019 (gmt 0)

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



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?

not2easy

9:09 pm on Oct 28, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



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).

phranque

11:02 pm on Oct 28, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



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"

lucy24

1:25 am on Oct 29, 2019 (gmt 0)

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



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”).

Lorel

6:08 pm on Oct 29, 2019 (gmt 0)

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



@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.

not2easy

6:20 pm on Oct 29, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



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. ;)

Lorel

3:45 pm on Oct 30, 2019 (gmt 0)

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



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.