Link structure change

New to mod_rewrite? This is a good place to start.

Link structure change

Postby alexjones » Tue Jul 21, 2009 3:35 am

I have a problem on how to redirect my old links to the new ones.
My old structure looks like: www.website.com/catalog/koi-fish-vector-pack.html

The new structure looks like: www.website.com/category/sub-category/k ... ector-pack

Any idea how can I do this?
alexjones
 
Posts: 9
Joined: Tue Nov 18, 2008 7:41 am

Postby richardk » Tue Jul 21, 2009 12:15 pm

How many URLs?
Does /category/sub-category change for different URLs?
Do you have access to the httpd.conf file?
Do you have a server-side language available (eg. PHP)?

If there are only a few
Code: Select all
Redirect 301 /catalog/koi-fish-vector-pack.html http://www.example.com/category/sub-category/koi-fish-vector-pack
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby alexjones » Wed Jul 22, 2009 1:16 am

Thanks for the reply, actually I have a lot of products in the shop. Here it's the url so you can see what is all about:
new site: www.designious.com
old site: www.designious.com/v2

I have like 5-6000 url's
I have access to httpd.conf
Server side language is php
alexjones
 
Posts: 9
Joined: Tue Nov 18, 2008 7:41 am

Postby richardk » Wed Jul 22, 2009 10:47 am

I have access to httpd.conf

Then you can use a RewriteMap, either a text file or (PHP) program.

For a text file map you would add
Code: Select all
RewriteMap oldtonew txt:/path/to/map.txt

to your httpd.conf file, and create a text file (map.txt) with the new and old URLs
Code: Select all
# Old New
koi-fish-vector-pack /category/sub-category/koi-fish-vector-pack

and the following to your .htaccess file
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond ${oldtonew:$1|failed} ^(/.+)$
RewriteRule ^catalog/([^/]+)\.html$ %1 [R=301,L]


For a program you would use
Code: Select all
RewriteMap oldtonew prg:/path/to/map.php

and instead of a text file you would write a program that returned to new URL (map.php).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby alexjones » Thu Jul 23, 2009 1:53 am

thanks for the help.
alexjones
 
Posts: 9
Joined: Tue Nov 18, 2008 7:41 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 26 guests

cron