0

I have migrated a static site to WordPress, now I need to redirect its pages, I have many URLs those will go one page, I can redirect one by one but those are many so I need a redirect rule that works for all.

For example, I have URLs like this

example.com/main-page/sub-page1/sub-page2/subpage3/
example.com/main-page/sub-page11/sub-page21/
example.com/main-page/sub-page5/sub-page25/subpage3/something.htm
example.com/main-page/sub-page1/

Now I want all subpages after /main-page/ will go example.com/main-page/

0

Try this rule in your .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/main-page/.*$ [NC]
RewriteRule ^(.*)$ http://www.example.com/main-page/ [R=302,NC,L]

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.