...

View Full Version : htaccess - redirect wordpress pages and categories



utnalove
06-21-2011, 03:10 PM
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

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

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


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

What's the difference?

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

Cags
07-09-2011, 08: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.

utnalove
07-09-2011, 10: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?

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

utnalove
07-12-2011, 11: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
http://glamourina.pl/tag/stradivarius
to
http://glamourina.pl/t/stradivarius

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

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

utnalove
07-13-2011, 05: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...

Inigoesdr
07-13-2011, 05: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.

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

utnalove
07-13-2011, 09: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