...

View Full Version : 301 reditect for dynamic URL in .htaccess



greens85
05-20-2011, 11:41 AM
Hi all,

This is something new to me and I'm really struggling to figure out the solution despite much time spend on google!

I need to use the .htaccess file to invoke a 301 from a dynamic url to another:

The old url format was:

http://domain.com/info_jobid_922.html

Obviously the 922 is dynamic jobid, which could be any number.

The new URL looks like so:

http://www.domain.com/educationjobs/Teacher of Maths-Northamptonshire-East Midlands-1187

I realize that these are different jobs, but hopefully you can see how the URL has changed.

The problem has come about by old style urls being cached by google which I now need to format onto the new style URL.

Can anyone help me out here?

Any help would be much appreciated.

Many thanks,

Greens85

gvre
05-21-2011, 01:17 PM
Try something like

RewriteRule ^info_jobid_(\d+).html$ http://www.domain.com/redirold.php?jobId=$1 [R=301,L]

In redirold.php get the jobId, build the new url and redirect [0] the user there.

[0]
header("HTTP/1.1 301 Moved Permanently");
header("Status: HTTP/1.1 301 Moved Permanently");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum