views:

77

answers:

3

We are using a mod rewritten URL within our PHP site, this is the rewrite rule we are using:

RewriteRule ^category/([^.]+)/([0-9]+)/([^.]+)/([0-9]+) categories.php?c_id=$2&filters=$3&_p=$4&area=category&areaname=$1

However, a user of a different system is switching to our setup and wants to 301 all their old pages to their new equivalents. So, for example, this URL:

http://domain.com/categories/clothing/5/1

becomes:

http://domain.com/category/clothing/5/0-0-0-0/1

Is it possible to do this in a single rewrite rule or rewrite match (or similar), my intial thought was something like this would work:

RewriteRule /categories/(.*)/(.*)/1 /category/$1/$2/0-0-0-0-0-0-0-0/1 [R=301,L]

it doesn't, any ideas?

Also tried this with RedirectMatch which also doesnt work:

RedirectMatch /categories/(.*)/(.*)/1 http://domain.com/category/$1/$2/0-0-0-0-0-0-0-0/1
A: 

Your example is redirecting the opposite way to the way you want it from what I can see.

/category/abc/def/0-0-0-0-0-0-0-0/1 to /categories/abc/def/1

Nat Ryall
just noticed i pasted them wrong way round, still not working though
seengee
switched them round above
seengee
+2  A: 

fixed myself with this rule:

RedirectMatch 301 /categories/(.*)/(.*)/(.*) http://domain.com/category/$1/$2/0-0-0-0-0-0-0-0/$3
seengee
+1  A: 

Here’s a mod_rewrite example:

RewriteRule ^categories/([^/]+/[^/]+)/([^/]+)$ /category/$1/0-0-0-0/$2 [L,R=301]
Gumbo