Forum Moderators: phranque
I need to capture the links and redirect them. I would like parse the data out and redirect to a new html friendly page (They are using Magento for the new site)
Can any one help with the basic on this?
I don't think you're actually expecting to execute aspx as php, since that won't ever work, but rather, you are simply wanting to redirect the old URLs to new URLs, and then to rewrite those new URLs (when requested from your server) to a script to generate the pages using php.
Take advantage of this opportunity to future-proof the site by eliminating all "file extensions" from your page URLs -- The files themselves will still have entensions, but the URLs don't need them. In this way, you will never have ".aspx", ".php". or ".html" in your page URLs any more. Carefully structuring your new URLs will assure that they won't need to change for any other reason, either -- ever again.
Jim
Options +FollowSymLinks
RewriteEngine on
RewriteRule ProdBySubCat-SubCat-(.*)-fd-(.*)\.htm$ ProdBySubCat.aspx?SubCat=$1&fd=$2
Here is an example of the incoming URL
http://www.example.com/products/ProdBySubCat.aspx?SubCat=11166&fd=1
the new site is at
[new.example.com...]
and I have my .htaccess file in /products/
What else do I need?
[edited by: jdMorgan at 12:48 am (utc) on July 13, 2009]
[edit reason] example.com [/edit]
However, if that's your incoming link posted above, then your rule is apperently backwards. The general form for a rewriterule is:
RewriteRule ^client-requested-local-URL-path$ internal-filepath or new-URL [L]
Also, avoid the use of ".*" subpatterns, and especially multiple ".*" subpatterns. While ".*" is fairly easy to comprehend, processing it is highly inefficient because it matches anything, everything, or nothing. Therefore, the matching engine must make many 'back-off-and-retry' attempts to find what characters it should and should not include in the match to that ".*" subpattern. The number of matching retries varies directly with the length of the 'tail' of the input string (that part not to be matched to ".*"), and geometrically with the number of ".*" subpatterns. Under worst-case conditions, only a few of these multiple-".*" subpatterns can have a discernible effect on the performance of a busy server.
For your query string, a negative match on ampersand or a numeric-only alternate character group would be much better, e.g.
RewriteCond %{QUERY_STRING} ^SubCat=([^&]+)&fd=([0-9]+)$
RewriteRule ^products/ProdBySubCat\.aspx$ http://new.example.com/ProdBySubCat-SubCat-%1-fd-%2.htm [R=301,L]