301 Redirecting Multiple Pages

6 replies
Hi,

I want to permanent redirect all pages from mydomain.com/tag/whatever to mydomain.com/tips/whatever.

Can I do that with one line of code in the .htaccess?

If yes, what is the code?
#301 #multiple #pages #redirecting
  • Profile picture of the author Sensei.Design
    I would use the following code:

    RewriteRule ^tag/(.*)$ /tips/$1 [L,R=301]

    Has been some time since I last needed this kind of htaccess
    {{ DiscussionBoard.errors[6777093].message }}
  • Profile picture of the author IronMike
    You would probably be better off using the redirection plugin to do this for you.
    {{ DiscussionBoard.errors[6777095].message }}
  • Profile picture of the author nobita436
    If you want to avoid the risk then you should use the plugin so that it can be done easily and also very reliably.
    You should try that before you make that happen.
    {{ DiscussionBoard.errors[6777847].message }}
  • Profile picture of the author Mister Ozzy
    I try to redirect all tags to a search about that tag.

    I wrote different rewrite lines in my .htaccess, but they don't work:

    RedirectMatch 301 ^tag/(.*)$ /?s=$

    RewriteRule ^tag/(.*)$ /?s=$ [R=301,L]

    What I also don't get is when to use RedirectMatch and when RewriteRule.

    My website is made with Wordpress and W3TC is running.

    How do I do this?
    {{ DiscussionBoard.errors[6780507].message }}
    • Profile picture of the author Mister Ozzy
      It almost works:

      RewriteEngine on
      RewriteRule ^tag/(.*)$ /?s=$1&search=GA [L,R=301]

      But the problem now is that the redirect links to:

      mydomain.com/?s=tag/&search=GA

      How can I get rid of the slash?

      Also, when a tag contains more than 1 word (for example the tag marketing tips) the redirect is:

      mydomain.com/?s=marketing-tips/&search=GA

      How do I convert that - symbol to a + symbol?
      {{ DiscussionBoard.errors[7018479].message }}

Trending Topics