Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Thanked 2 Times in 2 Posts

    301 reditect for dynamic URL in .htaccess

    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:


    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,


  2. #2
    Regular Coder
    Join Date
    May 2011
    Thanked 59 Times in 58 Posts
    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.

    PHP Code:
    header("HTTP/1.1 301 Moved Permanently");
    header("Status: HTTP/1.1 301 Moved Permanently"); 


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts