Why do my redirects only work when the original pages are still there?

0
2
Asked By CuriousCat219 On

I'm transitioning my website from static HTML to WordPress, and I've been setting up redirects for the original pages. At first, everything worked smoothly, but after I moved the original pages into a '/backup' folder to clean up, visitors started seeing 404 errors, indicating that my redirects were broken. I tried to find answers online, but the search results are mostly about how redirects should work for nonexistent pages, which isn't helping me. I've shared my redirect rules below—what am I doing wrong?

1 Answer

Answered By TechieTom82 On

It sounds like there might be a logic issue in your `.htaccess` file. Each `RewriteCond` only applies to the following `RewriteRule`, so if you have your redirect rules after a WordPress block or incorrectly placed, they might just get ignored. You need to make sure all your redirect conditions are correctly attached to each rule. Try reordering your file so that your redirects are prioritized before WordPress logic. Here's a simplified example to guide your setup:

`RewriteEngine On`
`RewriteCond %{HTTP_HOST} ^(www.)?issendai.com$ [NC]`
`RewriteRule ^japanese-courtesans/ages-of-courtesans.html$ https://issendai.com [R=301,L]`
Just make sure your redirects are on top, and the logic should start working again! Hope that helps!

CuriousCat219 -

Thanks, that makes sense! I’ll try rearranging my `.htaccess` now.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.