Forum Moderators: phranque
Now the new site is a PHP site and hosted on our Apache web server and the site is called www.example.co.uk.
The DNS was changed to route all traffic from the old one to the new site so if I put the old site into google it takes me to the new one. What I would like to do is redirect from the old URL to the new URL. I have tried to put a htaccess file on the Apache server but as soon as I do the redirect I cannot access the new website.
I can no longer access the old windows web server as the DNS is pointing all traffic to the new web site. When I search Google for Sale Grammar School it still brings up the old site. Any help would be appreciated.
[edited by: jdMorgan at 6:14 pm (utc) on July 14, 2009]
[edit reason] examplified [/edit]
If the old domain is not pointed to the new server, then getting that done is your first step.
If there is a fixed and predictable relationship between the old and new URLs, such as
oldomain.sch.uk/page-name.html -> newdomain.sch.uk/same-page-name.php
then you can redirect all page URLs with a single RewriteRule. If not, then I'm afraid that you'll have to write many rules, each of them a one-off for each old URL (Consider redirecting only the most important ones if you have more than a few hundred).
If you added code and it made your site inaccessible, then obviously there's something amiss with the code. But we can't comment further without seeing the code (or a representative sample of it).
Jim
If new filenames differ from old filenames only by their extension then there is no need to change the URL by which they are referred to 'out on the web'. Google has no need to know that your pages are now generated by PHP when they used to be generated by static HTML files. No need to know at all.
So don't redirect unless the requested domain is "old" or "wrong":
RewriteEngine on
#
RewriteCond %{HTTP_HOST} !^www\.example\.co\.uk$
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [R=301,L]
Jim
[edited by: jdMorgan at 6:52 pm (utc) on July 15, 2009]
To continue with what g1smd was telling you above, you should link to www.example.co.uk/ rather than to www.example.co.uk/index.php on all of your pages, and then if a client requests index.php, index.html or index.htm directly, you should redirect that request to "/".
This rule, inserted *before* the one above, would do that for index files in any directory:
RewriteCond %{THE_REQEUST} ^[A-Z]+\ /([^/]+/)*index\.(php¦html?)([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(php¦html?)$ http://www.example.co.uk/$1 [R=301,L]
Jim