Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts

    htaccess - redirect wordpress pages and categories

    Hello,

    in google webmaster tools I can see I have a lot of 404 because I changed the Wordpress category and aliases.

    I had the following:
    http://mysite.com/tag/tag1
    http://mysite.com/tag/tag2
    http://mysite.com/tag/tag3

    I changed the tag alias and now I have the following:
    http://mysite.com/t/tag1
    http://mysite.com/t/tag2
    http://mysite.com/t/tag3

    How can I tell google that http://mysite.com/tag/ permanently change to http://mysite.com/t/?

    Only with that ending /
    I do not want to redirect posts starting with the word tag. Eg. http://mysite.com/tagheuer-clocks must work fine.


    How can I do that?
    Thank youuu in advance

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Code:
    RewriteRule ^tag/(.*)$ /t/$1 [R=301,L]

  • Users who have thanked Cags for this post:

    utnalove (07-12-2011)

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    Thanks, in the meantime my hosting provider told me to use this one:

    Code:
    RedirectMatch 301 /tag/(.*) /t//$1
    What's the difference?

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Should be functionally the same. You have an extra slash in the RedirectMatch one, though.

  • Users who have thanked Inigoesdr for this post:

    utnalove (07-12-2011)

  • #5
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    The difference is that RewriteRule is a directive of mod_rewrite and RewriteMatch is a directive of mod_alias. Essentially speaking in your case they will do pretty much the same job. Whilst mod_rewrite is probably a more flexible tool, it's my understanding that RewriteMatch may be slightly quicker in cases that it can handle.

  • Users who have thanked Cags for this post:

    utnalove (07-13-2011)

  • #6
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    Thank you, so I understand I can choose the one I prefer.

    But what about the slash? What is the difference in terms of additional slash?

  • #7
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    So far as I can tell it's not required, just remove it.

  • #8
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    hmm... I have the following code in the htaccess but it's not working:

    Code:
    RedirectMatch 301 /tag/(.*) /t//$1
    It should redirect for example
    http://glamourina.pl/tag/stradivarius
    to
    http://glamourina.pl/t/stradivarius

    But it's not redirecting...
    where's the error?

  • #9
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Remove that extra slash for one thing. That code works for me. You should check your error log to see if there is a syntax error somewhere, too.

  • Users who have thanked Inigoesdr for this post:

    utnalove (07-13-2011)

  • #10
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    yeah, it was working when the site was hosted in another ISP... in this new one it's not working anymore

    hmm... I have now

    Code:
    RedirectMatch 301 /tag/(.*) /t/$1
    but still it's not working.... I do not have access to php logs, but I will open a case with the hosting provider...
    Last edited by utnalove; 07-13-2011 at 04:08 PM.

  • #11
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    It's possible your host has an older version of Apache with mod_alias disabled or restricts .htaccess files. The PHP logs are not what you are looking for. Apache has it's own error logs that would contain the info you're looking for. You should ask your host what version of Apache they are running, if they have mod_alias installed, and if you are allowed to use the RedirectAlias command in your .htaccess files.

  • Users who have thanked Inigoesdr for this post:

    utnalove (07-13-2011)

  • #12
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    mmm... ok thanks, I'll try to find it out
    Last edited by utnalove; 07-13-2011 at 04:41 PM.

  • #13
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    Workarounded: they are not using Apache.
    RedirectMatch is not supported. I had to use RewriteRule.

    Thank you all


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •