Any .htaccess gurus here? | FerrariChat

Any .htaccess gurus here?

Discussion in 'Technology' started by TestShoot, Jun 4, 2010.

This site may earn a commission from merchant affiliate links, including eBay, Amazon, Skimlinks, and others.

  1. TestShoot

    TestShoot F1 World Champ
    Silver Subscribed

    Sep 1, 2003
    12,288
    Beverly Hills
    I have a client, and their genious programmer set a pagebase f-up. For 12 of 130 files, they have a custom css linked, but it is a PITA to rework. They got my number from a former employee and are blowing up my phone.

    Me = Obi Wan = their only hope != profit

    <link rel="stylesheet" href="/css/<?php echo $pageBase; ?>.css" type="text/css" />

    What I want to do is capture 404 errors in the /css/ directory and redirect to a 404.css so the damned site will validate without errors because some genious showed them the W3C validator and any broken link is cause for widespread panic. For the life of me, I can't figure that out.
     
  2. becker

    becker Formula Junior

    Feb 20, 2001
    340
    Arlington VA
    Full Name:
    Becker Cuéllar
    what is the backend?? .NET , linux,???? Web server???
     
  3. TestShoot

    TestShoot F1 World Champ
    Silver Subscribed

    Sep 1, 2003
    12,288
    Beverly Hills
    it is a linux server, php5 site. shared hosting, so i can't do too much, but i may just not care on this lol
     
  4. RayJohns

    RayJohns F1 Veteran
    Silver Subscribed

    May 21, 2006
    7,920
    West Coast
    Full Name:
    Ray
    #4 RayJohns, Jun 6, 2010
    Last edited: Jun 6, 2010
    .htaccess is a username/password system based on flat files. It doesn't have a lot to do with trapping web server 404 errors - unless I'm not understanding your question.

    Normally, if you want to trap 404 errors (i.e. web page not found), you would configure that in the httpd.conf file (assuming you are using apache). You can setup a redirect or however you want to configure it, so that the server directs the client to a specific page (e.g. a fancy little "page not found" page). Or you can just loop the server back to the home page if you want also.

    Again, I'm not sure what .htaccess has to do with all that. .htaccess normally is used along side .htpasswd as a means to secure a section of a website so that users are prompted for a username/password. That's different than the server handling missing pages when requested by the client.

    If what you are attempting to accomplish here is to have the server step in and serve up a page in order to avoid an error that is actually present in the relative links in a web page, then the correct method is to fix the error, not tweak the server to make things work with the error present. Not only does that induce more load on the server (and network), but it's just a kludgey method at best for addressing (or in this case, not addressing) the root of the issue.

    If the error is present across a large number of web pages, then issue a command like this in Unix:

    perl -pi -e 's/error string/fixed string/g' *.html

    where *.html is the matching files that need attention. The above perl line will do a global "edit" using a search/replace on any matching files. Once the changes are in place, you won't need to trap 404 errors.

    Ray
     

Share This Page