Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Represent 404 as 301

  • 10-10-2005 7:11pm
    #1
    Closed Accounts Posts: 53 ✭✭


    Hi guys

    I have moved a site from an old server where we had a mix of PHP/HTML files, but on the new server all pages are PHP files.I don't want to recreate all the old HTML files on the new server and have all outward links from them going to PHP pages.

    I know that you can do something with mod_rewrite in Apache, but as a temporary fix I have done the following:

    Create .htaccess file:

    [HTML]ErrorDocument 404 /404.php [/HTML]

    and the corresponding PHP page gives a 301 header

    [PHP]<?php
    header("HTTP/1.0 301 Moved Permanently");
    header ('Location: /index.php');
    ?>[/PHP]

    For the average punter, this is fine, but I want to have it so that serach engines won't get the 404 error in the first place so as to not affect Google rankings etc.

    Any help appreciated on the easiest/best way to do this.

    Thanks

    Enda
    --


Comments

  • Registered Users, Registered Users 2 Posts: 2,170 ✭✭✭Serbian


    You really should look at mod_rewrite, and do it soon or else you could seriously damage the rankings that your site is getting. It's not that hard really, especially if it is a simple matter of rewriting the file extension from .html to .php (i.e. the files all have the same name). I don't think a 404 followed by a 301 is going to do you any favours.

    ModRewrite.com is probably a good place to start, though the forum is extremely inactive. If you post here what the general file structure looks like, we can try and help you write the rules.


  • Closed Accounts Posts: 53 ✭✭endanagle


    Hi Serbian,

    You're right.. the forums there are pretty much 'inactive'!.

    Basically, what I would like to do is if someone looks for say:

    aaa.html, the mod_rewrite sends them to aaa.php, and if aaa.php doesn't exist, then they are sent to the index.php page.

    Is this possible? If not, even to have the html > php redirect would be great.

    Thanks for the help

    Enda
    --


  • Registered Users, Registered Users 2 Posts: 7,740 ✭✭✭mneylon


    That should be easy enough to do. If you look at the examples in the documentation you should get an idea of what you need to do:
    http://httpd.apache.org/docs/2.0/misc/rewriteguide.html


Advertisement