How can I find links and match Old with New dynamic pages for same website to make the redirect easy and faster?

Hello everybody.
Sorry if this topics do not go in this forum category, I did not know where to place it.

I have updated a web site. Before, it had index.php and Articulos.php two dynamic pages that generated the web site. With the new changes the site has now another two pages that will dynamically generate the New web site: resumenes.php and contenido.php The Old dynamic pages are still running as well as the New dynamic pages.

I do not want they lose any position in the search engines, so I need to redirect the old dynamic pages to “approximately” the new ones, that are pretty much the same in content but not 100% equal. Unfortunately the dynamic links (URLs) are complete different, except for the domain part of the link which is the same, and I do not have a permalink option.

I know how to make a single redirect using the .httaccess file but since both, Old and New site, are generated by dynamic pages, I need a tool that allow me to crawl each link on both the Old and the New site and if possible try to match links by similar keywords, that I know are in each page of the New Site, so I can match Old and New links more easy. I do not know if there exist such a tool. I also need to know all the website’s pages that has indexed.

After doing the redirect sucessfully, I will delete the old dynamic pages.

Thank you and best regards


PPPPPPP (proper prior planning prevents piss poor performance).

The easy way is to go back to how you populated the new database. If you used the old database, the articles would not be “approximately” similar to the old database records but they should be using the same database records. Yeah, but the world wasn’t built that way … nor your CMS apps.

Option #2 is to utilize a “handler script” to remap your old database’s articles to the new database’s articles. Your .htaccess file would redirect any requests to the old pages to the handler script which would lookup the “approximately” equivalent record in the new database and request the appropriate dynamic script to serve that request (with an R=301 status in the header() redirection). Note that this is the “poor man’s RewriteMap” which is not available to you without access to the Apache config files.

Google? Why be specific and only do a half*** job with the redirection - redirect everything you can and “fill in the blanks” in the new database.



Hello and thanks dklynn,
I found a nice application and got 94 dynamic links on the old website pages then I found the corresponding pages on the new dynamic pages and then I made a table with the 301 redirect, and found that things are very complex with regards to dynamic redirection if we do not plan in advance, yes you are right, but it is a little late for me.

So I followed a simple tutorial to create only one redirection to test, I also used the cPanel output for Canonical URL, and the .htaccess file is as follows, but the redirection does not work:

RewriteEngine on

RewriteOptions inherit

DirectoryIndex resumenes.php
ErrorDocument 404
Options All -indexes

RewriteCond %{HTTP_HOST} ^mywebsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.com$

RewriteCond %{QUERY_STRING} ^categoria_no=1$ [NC]
RewriteRule index\?categoria_no=3 [L,R=301]

This validator passed fine the above code

I also tried with this in the last line, also validates but did not work:
RewriteRule ^index\.php\?categoria_no\=1$ "http\:\/\/mywebsite\.com\/resumenes\.php\?categoria_no\=3\&locale\=es" [R=301,L]

The old page:
should go to:
but is not working.
I know it would be easier if both categoria_no numbers were the same, but the menu items have changed with new subcategories that were not present in the old website pages and this change moved almost all pages to new menu categories.

Any idea is appreciated, if I solve this I will apply same syntax for the rule to the rest of the redirections and they should work once this works.
Thank you and regards

Hi jj!

Your code looked okay until the validator comment where your RewriteRule specified the query string, too. Remember, the RewriteRule can ONLY examine the {REQUEST_URI} string (the rule’s associated RewriteCond statements can match any other server variable, i.e., {QUERY_STRING} as you had done in your prior code.

Now, back to my recommendation: IF you can map each categoria_no to your new categoria_no set, all you need to do is create a handler file (error document which can examine the requested query string for the categoria_no and redirect to the resumenes.php script with the new categoria_no). Actually, you could use the old index.php file to do that for you without making a redirection to a handler script.

To do this, save your old index.php file then create a new one with an array whose keys are the old index numbers and the values as the new index numbers. Then simply use header() to set the status as 301 before using a second header() statement to redirect to resumenes.php script with the $redirection[$categoria_no] from the array - this would be simpler and faster than creating a database table mapping old to new.

This is what I term a “poor man’s RewriteMap” which is all most webmasters have available (because a RewriteMap, done incorrectly, can take a server down so it’s only available in the server’s .conf files).