Home wp Blog and Feed Not Working After Moving WordPress to Root

Blog and Feed Not Working After Moving WordPress to Root

0
Blog and Feed Not Working After Moving WordPress to Root

Introduction

I had this issue when I moved my blog from /blog/ to the main domain /.

I did not move the WordPress files. They were still inside /blog/. Only URL was changed.

At first, everything looked okay. Homepage opened. Posts opened. No clear error.

Then I checked old links.

  • /blog/ was opening a random page
  • /blog/feed was showing a comment feed of some old post

That is when I understood something is wrong.


What I Changed

Before:

  • Blog was at /blog/

After:

  • Blog moved to /
  • Files still inside /blog/

In settings:

  • Site Address → root
  • WordPress Address → still /blog/

Then I added rewrite rule in .htaccess to handle URLs.


Where It Went Wrong

This line in .htaccess caused the problem:

RewriteRule ^(.*)$ blog/$1 [L]

It looks simple, but it breaks things.

What it does:
Every request goes to /blog/.

So:

  • /blog/ becomes /blog/blog/
  • /blog/feed also goes wrong

WordPress does not understand this properly.

Then it tries to guess.
That is why random page or wrong feed shows.


Main Problem

The biggest issue is feed.

Feed readers don’t show error.
They just stop updating.

So your subscribers stop getting posts, and you may not know.


What Fixed It

I removed that rewrite rule.

Then I did two simple things.


Step 1: index.php in Root

I created index.php in main folder.

<?php
define('WP_USE_THEMES', true);
require('./blog/wp-blog-header.php');

This connects root URL with WordPress inside /blog/.


Step 2: Proper Redirect

Then I added 301 redirects for old URLs.

Redirect 301 /blog/ https://www.yoursite.com/
Redirect 301 /blog/feed https://www.yoursite.com/feed
Redirect 301 /blog/feed/ https://www.yoursite.com/feed/

And kept normal WordPress rules below it.


Why 301 Matters

301 means permanent change.

It tells browser and feed readers to update URL.

Without this, old links keep getting used.


Settings Check

In WordPress settings:

  • WordPress Address → /blog/
  • Site Address → /

This is important.


How I Tested

I did not trust browser.

I used:

curl -I https://www.yoursite.com/blog/

It showed 301.

Then:

curl -I https://www.yoursite.com/feed

It showed 200.

That means feed is working.


Final

The problem was small but confusing.

Wrong rewrite rule was breaking URLs.
WordPress was trying to adjust, but results were wrong.

After removing that rule and adding proper redirect, everything worked fine.

Old links started working.
Feed started working again.

LEAVE A REPLY

Please enter your comment!
Please enter your name here