g1smd

msg:4551316 | 10:02 am on Mar 5, 2013 (gmt 0) |
It is very bad form to mass redirect to the home page. It's a signal of "low technical quality" as far as Google is concerned. You should redirect to the equivalent page.
|
mrdave

msg:4551325 | 11:18 am on Mar 5, 2013 (gmt 0) |
Hi, okay i can do that, always listening and learning ! do i need to specify them in all big list then as there is nothing in the original url apart from the number that can identify the new product url? There is no relationship between the old number and the new url. It seems like a slow method rule 1=1, would rather have a rule where 1 redirect pattern will cover 500+ ? any other ideas?
|
g1smd

msg:4551328 | 11:34 am on Mar 5, 2013 (gmt 0) |
You could rewrite (rewrite, rather than redirect) those requests to a simple PHP script that contains an array of old and new URLs where the PHP script will send the redirect (or will send 404 if the old URL is not found in the array). This is one line of htaccess code (plus an extra exclusion before your non-www/www canonicalisation rule) and a few lines of PHP code (plus the array of however many URLs we're talking about).
|
mrdave

msg:4551348 | 1:16 pm on Mar 5, 2013 (gmt 0) |
yes rewrite i think is the way... thanks..
|
g1smd

msg:4551414 | 4:15 pm on Mar 5, 2013 (gmt 0) |
This goes near the start of the root htaccess file:
RewriteRule ^product([0-9]+)\.php /fix-me.php?id=$1 [L] You'll also need a RewriteCond as part of your existing non-www/www canonicalisation rule:
RewriteCond %{REQUEST_URI} !^/fix-me\.php$ otherwise non-www requests for old URLs will expose the fix-me script as a new URL on www. The PHP script contains an array: 1 => /new-page-for-one 9 => /new-page-for-nine and simply looks for the new URL given the old ID. It then uses the HEADER directive to send a 301 response. When there is no new URL for the old ID found in the array, the PHP script MUST send a 404 Not Found status code.
|
lucy24

msg:4551531 | 10:44 pm on Mar 5, 2013 (gmt 0) |
| This goes near the start of the root htaccess file: |
| Generic question now that it has come up. When you've got a redirect that's too complicated for htaccess alone, so a detour to a php script is required, there are really two things happening. First the htacces rewrite to the php stuff; then the php redirect to the target page. In this situation, would the RewriteRule be located as if it were a redirect-- that is, after the hard-coded [F] and [G], before most of the [R=301,L] --even though on the surface it's "only" a rewrite [L]?
|
g1smd

msg:4551548 | 11:26 pm on Mar 5, 2013 (gmt 0) |
The "rewrite to special PHP script" can go in one of two places. 1. After rules that block and indeed after rules that redirect, down there where "normal" rewrites usually go. This is usually NOT a good idea because non-www requests for the old URL will be redirected to www before the rewrite kicks in to the PHP script which then issues its own redirect. Non-www requests for the old URL will create a two-step redirection chain:
non-www OLD URL -> www OLD URL -> www new URL It's also possible that some other earlier more general rule will match the request and produce the wrong result. 2. After rules that block and before rules that redirect. Ultimately, URL requests that match the RegEx pattern will be redirected (by the PHP script). I prefer this, as it means all requests that will be redirected are listed before the non-www/www canonicalisation rule (it usually also nicely fits the required ordering from most specific to most general too). However, you MUST add the fixup PHP script path as an exclusion to the non-www/www rule, otherwise non-www requests for old URLs will be redirected to a www URL with the PHP script location as the path:
non-www OLD URL -> www PHP script -> www new URL Again, this multiple step redirection chain is a bad thing, and the extra RewriteCond attached to the non-www/www canonicalisation rule prevents it happening. I remember a site that had hundreds of thousands of old URLs that needed to be redirected via just such a PHP script. To invoke the PHP script(s), just five RewriteRules were needed. These went at the top of the htaccess file right after rules that block access to malicious requests. All other requests breezed through these five rules without matching and on to the more normal sort of htaccess code below.
|
|