htaccess 404重定向字符串?

On domain.com is hosted a blog with permalinks set up as domain.com/article and domain.com/category.

Now, the blog is moved to domain.com/blog and some other content is put directly on domain.com : file2.php , filex.php

Now, how can you make a redirect when users enters on domain.com/articlex to be redirected to domain.com/blog/articlex ?

To don't interfere with the new content, i'm thinking to redirect 301 the 404 page response.

I'm trying in .htaccess with ErrorDocument 404 404.php, and from there to make a 301 redirect but there is no $_SERVER[REQUEST_URI] available.

Also, with RewriteCond %{ENV:REDIRECT_STATUS} = 404 to redirect with query strings I had no success.

You can use .htaccess to point not found pages to page where you will make redirects

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* redirect.php [L]

And in redirect.php write code you planned for 404.php, you will have $_SERVER[REQUEST_URI] available there, also you need to handle not found pages in redirect.php file