UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 31st May 2008, 04:19 PM   #1 (permalink)
pjrobertson
Registered User
 
Join Date: Jun 2007
Location: Wales, UK
Posts: 36
exclude certain files from .htaccess redirect

Well, I've just moved all my files from .html to .php but most search engines still point to the html files.

I've made a .htaccess file with this in:

Code:
Options +FollowSymLinks
RewriteEngine On
RedirectMatch 301 (.*)\.html$ $1.php
ErrorDocument 404 http://example.co.uk/error_docs/404.html
Which works, except I have some pages (as you can see, 1 is the 404 page) that need to stay as html. Some others are the googlesitemap validation file.

I've looked at

RewriteCond %{REQUEST_URI} !^/error_docs$


but I can't seem to get it to work. What's the best way of excluding files

the files I have are:

/error_docs/404.html
google466e821b876059fa.html

and a few folders such as
/design/
/scripts/

and a few others.

So as not to make a new topic: a few other things.

the 404 redirect:

sites like amazon.co.uk DON'T redirect the user to a new page if they get a 404

e.g. if you go to http://amazon.co.uk/adkfhkh
the error show up on that page as opposed to being sent to amazon.co.uk/custom404page.html

is there a way of doing this?

The final thing:

I recently updated the diary / blog on the site to wordpress (from 100% manual!)
so I have pages like
nov07.html
dec07.html
etc. that I want to redirect to /diary/

is there a way of doing this?

I've tried

Code:
RedirectMatch 301 (.*)07\.html$ /diary
thanks

Last edited by pjrobertson : 2nd June 2008 at 04:27 PM.
pjrobertson is offline   Reply With Quote
Old 31st May 2008, 10:21 PM   #2 (permalink)
Samizdata
Virtual Dilettante
 
Join Date: Nov 2006
Location: Planet Earth
Posts: 182
Quote:
Originally Posted by pjrobertson View Post
I've just moved all my files from .html to .php but most search engines still point to the html files.
I'm afraid this is an "I wouldn't start from here" question - better to have done this:

Code:
# Parse html as php
AddType application/x-httpd-php .html
AddHandler application/x-httpd-php .html
AddType text/html .php 
AddHandler php-script .php .html
All your .html pages would have turned into .php by magic (or something similar).

Quote:
Originally Posted by pjrobertson View Post
sites like amazon.co.uk DON'T redirect the user to a new page if they get a 404
That's because they have the correct code (relative path):

Code:
# Custom error
ErrorDocument 404 /error_docs/404.html
Any links in the 404.html (including CSS and images) should be absolute.

Quote:
Originally Posted by pjrobertson View Post
I want to redirect to /diary/
Something like this should probably work:

Code:
# Set options
Options +FollowSymlinks
# Turn on mod_rewrite
RewriteEngine On
# If file has required ending
RewriteCond %{REQUEST_URI} 07\.html$
# and is not in diary
RewriteCond %{REQUEST_URI} !^/diary/
# Redirect to file of same name in diary
RewriteRule ^(.*)$ http://www.example.com/diary/$1 [R=301,L]
...
__________________
The Silhouettes - 50th Anniversary Website
Samizdata is offline   Reply With Quote
Old 1st June 2008, 09:36 AM   #3 (permalink)
pjrobertson
Registered User
 
Join Date: Jun 2007
Location: Wales, UK
Posts: 36
Thanks Samizdata.

A simple solution to the 404 error document problem, and my wordpress / diary redirect no works great

Unfortunately I've changed all the pages to php now,
would the best solution be to just select the ~20 pages that are now .php in the .htaccess and redirect them as opposed to using wildcards, or would this make the loading of pages slower (because of parsing etc.)?

Thanks again
pjrobertson is offline   Reply With Quote
Old 1st June 2008, 07:48 PM   #4 (permalink)
Samizdata
Virtual Dilettante
 
Join Date: Nov 2006
Location: Planet Earth
Posts: 182
Cool URLs Don't Change

I'm not sure I entirely understand your situation, but here are a few thoughts.

Cool URLs don't change - I would expect a drop in rankings (possibly for months) if you get this stuff wrong.

If, as you say, the search engines are still pointing to your .html files it may not be too late to change the extensions back and use the code I posted to have them parsed as php - but I would be paying very close attention to what GoogleBot has been doing in your site logs.

If there are only twenty files then renaming them will be a quick job, and though you will obviously have to change your internal links as well the whole process can be done very quickly with the find and replace feature of Dreamweaver or any good text editor.

External inbound links are beyond your control so if you are determined to change to the new .php extension then you need to use 301 redirects in .htaccess for all of them, though it is usually possible to do this without writing a line for each individual file.

I would not expect any difference in page loading times whichever way you go.

I wish you luck.

...
__________________
The Silhouettes - 50th Anniversary Website
Samizdata is offline   Reply With Quote
Old 2nd June 2008, 08:06 AM   #5 (permalink)
pjrobertson
Registered User
 
Join Date: Jun 2007
Location: Wales, UK
Posts: 36
I think I'll take your advice then...

googlebot has indexed my new sitemap (with .php links) and has indexed some of my .php pages, but from what you say I may lose some rankings.

Thanks for your help!
pjrobertson is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 04:50 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309