0

i feel my question is simple but I am definitely not a pro at regex. I am looking to redirect every page possible to a single page on the same site.

For example: currentsite.com and anything else that could be a path like currentsite.com/about or currentsite.com/company should be redirected to currentsite.com/mainpage

When i tried using the following /(.*) as the relative url to match it basically tries to redirect everything including the currentsite.com/mainpage causing too many redirects.

I am doing this in wordpress using the redirection plugin that allows to use regex. Any help will be appreciated.

user2189801
  • 83
  • 1
  • 1
  • 11
  • Does this answer your question? [Regex: match everything but a specific pattern](https://stackoverflow.com/questions/1687620/regex-match-everything-but-a-specific-pattern) – InSync Jul 04 '23 at 21:15

1 Answers1

0

You can use htaccess redirect its fast

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^example.com [OR]
  RewriteCond %{HTTP_HOST} ^www.example.com
  RewriteRule (.*) https://example.com/mypage [R=301,L]
</IfModule>

insert this code to end of htaccess file in wordpress main folder and change "exmaple.com" by your domain name. redirect by htaccess is nice

ayoob zare
  • 76
  • 5