Redirect the page if the URL has content string using htaccess

22 views Asked by At

I have more than 200 URLs showing 404 on my page and below is the example

https://www.example.com/content/xyz-numbers

I have to redirect all the URLs to the home page so I thought if the URL has a content string then redirect to the home page.

I have tried the below code but not working. Would you help me out with the correct code?

1

RewriteEngine on

RewriteCond %{REQUEST_URI} content
RewriteRule ^ https://www.example.com/ [L,R]

2

RewriteCond %{REQUEST_URI} content
RewriteRule .* https://www.example.com/

3

RewriteRule ^content/(.*)$ https://www.example.com/$1 [R=301,L]

4

RewriteCond %{REQUEST_URI} /content/ [NC]
RewriteRule ^(.*)$ / [R=301,L]
0

There are 0 answers