PDA

View Full Version : some mod rewrite help?


ses5909
12-26-2007, 05:58 AM
I am now using tags instead of categories and I would like to redirect the categories to their corresponding tag. I tried adding:

RewriteRule ^category/(.*)$ /tag/$1 [L]

I suck with mod rewrite so please tell em where I am going wrong!

BPartch
12-26-2007, 06:32 AM
Not sure if it will work, but try:Redirect /category http://www.ilovecode.com/tagAssuming this is the site you meant, if not change the URL. :)

Jelena
12-26-2007, 08:23 AM
Try this:

RewriteRule ^category/([^/]+)$ /tag/$1 [L]

ses5909
12-27-2007, 01:12 PM
Your's worked Ben, thanks! Jelena, I tried yours but it didn't work either.

SO can someone tell me why to use redirect vs. RewriteRule?

ses5909
12-27-2007, 01:28 PM
Also, does redirect affect the SEs ability to follow the page or is there one that is better in the eyes of SEs? I don't want to lose what I already have indexed.

SarahG
12-28-2007, 05:13 PM
What exactly do you want to accomplish? At present Ben's method does a temporary redirect (so returns 302). RewriteRule will work providing the RewriteEngine is set to on and it also depends on your base directory.

Ideally you need either of the following, both would return a 301 to the SE spiders and neither is different in their eyes, providing the 301 is there, so that your old pages eg /category/jobs/ would be replaced with /tag/jobs/

Redirect 301 /category /tag

or

RewriteEngine On
RewriteBase /

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

Also, this needs to be above the WordPress permalink code, which could be why the same line of code didn't work initially.

BPartch
12-28-2007, 05:59 PM
Thanks for the info SarahG :)

What exactly do you want to accomplish? At present Ben's method does a temporary redirect (so returns 302). RewriteRule will work providing the RewriteEngine is set to on and it also depends on your base directory.

Ideally you need either of the following, both would return a 301 to the SE spiders and neither is different in their eyes, providing the 301 is there, so that your old pages eg /category/jobs/ would be replaced with /tag/jobs/

Redirect 301 /category /tag

or

RewriteEngine On
RewriteBase /

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

Also, this needs to be above the WordPress permalink code, which could be why the same line of code didn't work initially.

ses5909
12-28-2007, 06:43 PM
Thanks Sarah. I will put it above the wp permalink code and see if that does the trick. Since I removed my categories and replaced them with tags, I simply wanted to do a 301 redirect.