View Full Version : htaccess - redirect wordpress pages and categories

06-21-2011, 02:10 PM

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:

I changed the tag alias and now I have the following:

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

07-08-2011, 10:51 PM
RewriteRule ^tag/(.*)$ /t/$1 [R=301,L]

07-08-2011, 10:58 PM
Thanks, in the meantime my hosting provider told me to use this one:

RedirectMatch 301 /tag/(.*) /t//$1

What's the difference?

07-09-2011, 03:46 AM
Should be functionally the same. You have an extra slash in the RedirectMatch one, though.

07-09-2011, 07:23 AM
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.

07-09-2011, 09:27 AM
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?

07-09-2011, 02:33 PM
So far as I can tell it's not required, just remove it.

07-12-2011, 10:05 PM
hmm... I have the following code in the htaccess but it's not working:

RedirectMatch 301 /tag/(.*) /t//$1

It should redirect for example

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

07-13-2011, 03:53 PM
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.

07-13-2011, 04:04 PM
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

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...

07-13-2011, 04:30 PM
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.

07-13-2011, 04:38 PM
mmm... ok thanks, I'll try to find it out

07-13-2011, 08:22 PM
Workarounded: they are not using Apache.
RedirectMatch is not supported. I had to use RewriteRule.

Thank you all

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum