Ive got an issue with one site (soon to be 2) where I have changed the url file name from example : .site.co.uk/prices.html to
.site.co.uk/PAT_testing_prices.html (In my latest adventure of delving into SEO)
Should I be using a .htaaccess redirect in this situation as my old URL`s are still ranked in some instances page 1 of google/yahoo, but when the link is clicked, it throws up a this file could not be found be found on the server,thus loosing a potential viewer/customer…
Will the search engines love me or loathe me for using it ?
And where should this code be uploaded to, meaning in the <head> of the new file or in a completely new html file uploaded to the root folder on the server - If the later what should the html file be called ?
Any help will be greatly appreciated
p.s Apologies if this is in the wrong forum - please relocate to suit - Thankyou
[Thread moved to Apache forum, as that deals with .htaccess.]
Basically, if the old page no longer exists or has been renamed, you want people to redirected to the new page. So yes, set up a .htaccess file (in the root folder on your server) and redirect the old page to the new.
But the old URL`s are still ranking on page 1 of the SERPS, and not the newer html file name - Does this mean Im just going to have to wait for the old files to drop out of the SERPS, eventually being overidden by the new html file name. Because I havnt got an “old” file to place a re-direct in. In hindsite I should have uploaded a brand new html file with the new name, and then placed the .htaaccess file in the old file, thus resulting in a “re-direct”…
Ive just spoke (via typing) to the online help for my web hosting company and they have said to write the following :
and then save the file type as a .htaaccess file and just upload it to the root folder
Yes, that’s fine. Only problem is that is can be tricky to work with a file starting with a dot on your computer. so you may need to name it something like htaccess.txt, upload, then rename on the server. Or just go straight to the server and create it there with the correct name (though there is often one there anyway). It’s worth checking on the server first, and check if there’s anything in the .htaccess file first. Uploading a new one will overwrite the old one, so you’d lose anything in there already.
Poor Ralph! Anyway, thanks for moving ben to Apache.
ben,
If your redirections are simply to prepend PAT_testing_ to a few .html files, that’s a job that mod_alias is better suited for (the Redirect series of commands). If you need to check whether the old files still exist or not (because you didn’t rename ALL your .html files), then mod_rewrite has the power to do that.
is the mod_alias version which is much faster because mod_alias is part of Apache’s core and doesn’t require the regex engine (at least the non-regex versions of mod_alias directives don’t). The redirection in red is REQUIRED to be an absolute redirection (I’ve used the “internal” version with the leading / rather than http://domain/…).
If you need to check whether prices.html still exists before making such a redirection, mod_rewrite is the tool to use:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^prices\\.html$ PAT_testing_prices.html [R=301,L]
Of course, ‘prices’ in this example can easily be extended to capture all (lowercase) filenames by replacing ‘prices’ with ‘([a-z]+)’ in the regex and ‘$1’ in the redirection (all without the single quotes!).
The R=301 flag tells search engines that you’ve moved the page so they will thank you by moving the file in their db, too, which will have the effect of saving your PR. Otherwise, you’re starting afresh on the PR for the “new” page.
WHERE should it be loaded? OMG! That’s what your .htaccess file is for! PLEASE read the tutorial Article linked in my signature for more information (and sample code) about Apache’s mod_rewrite.
Your host gave the same answer (for few files) as above EXCEPT that they used the full (absolute) redirection whereas only the internal (absolute) redirection is necessary. Okay, EITHER if fine but the mod_alias redirection MUST be absolute!
David… I can see your a whizz at this stuff, I must point out im not! I have about as much knowledge in programming as flight time clocked up in space, so excuse me for being, well to put in bluntly “thick” but Im kinda confused. I have tried to read your explanation on your site, but most of it is going over the top of my head.Im not the brightest of stars or should that be spacedust!
what I will say is Ive created a .htaccess file with the following in, is this suffice to redirect the old URLs to the recently renamed URLs ? :
That’s a good sign … but it only applies to mod_rewrite. Redirect is the simple version (mod_alias) which is part of Apache’s core so it can’t be turned off.
Aw, that’s the same thing as the simple Redirect statements but (not) using the power of mod_rewrite’s regex engine (after delaying to load the engine for EVERY request). In other words, it’s important to know the correct tool and, for four simple redirections like this, Redirect is the correct tool (because it’s fastest).
As for the tutorial, if you have questions, the fastest way to contact me is via e-mail, i.e., the contact form on the website. Do not be afraid to ask as that’s the best way to clear away the cobwebs!
The requested URL /legislation.html was not found on this server."
This example of the search query isnt too bad as there is more than 1 instance of the site in the SERPS. When it does cause problems, is when there is only 1 result for the site in the SERPS and its that link which is deceased, so Ive effectively lost a user as they would just carry on searching through the rest of the SERPS on that particular page.
The File Not Found is on your server and the Redirect statements should redirect visitors just as it redirects SEs’ spiders. The 301 is important to the SEs, though, as it tells them to update their database. Time? It will take the SEs weeks to come around to re-spider your website (which could be sped-up SLIGHTLY by registering the pages again).