How to add redirect in htaccess for all urls not cotaining specific string?

I’m having some htaccess issues with my wordpress blog. My previous url’s were something like

article-name.html

Read More

Now I changed the structure to

blog/article-name.html

But I’m still getting 404 for old url’s I shared on various other sites. I’ve tried adding in htaccess a rule, also tried “redirection” plugin with no success:

enter image description here

and in .htaccess I tried:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!blog/).)*.html$ - /blog/$1.html [L]
</IfModule>

Related posts

Leave a Reply

2 comments

  1. Your regex appears to be a problem, try this:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^((?!blog/).+?.html)$ /blog/$1 [L,R=301,NC]