How do you redirect all 404 requests to a specific page, regardless of the subdomain?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Myst
    Confirmed User
    • Feb 2004
    • 4708

    #1

    How do you redirect all 404 requests to a specific page, regardless of the subdomain?

    Anyone know how to do this?

    Basically all 404 requests to *.domain.com/* goes to domain.com/404.html
    ICQ: 298-523-037
  • Myst
    Confirmed User
    • Feb 2004
    • 4708

    #2
    bumpbump
    ICQ: 298-523-037

    Comment

    • chris01282
      Confirmed User
      • Feb 2005
      • 370

      #3
      RewriteEngine On
      ErrorDocument 400 http://www.domain.com/404.html
      ErrorDocument 401 http://www.domain.com/404.html
      ErrorDocument 403 http://www.domain.com/404.html
      ErrorDocument 404 http://www.domain.com/404.html
      ErrorDocument 500 http://www.domain.com/404.html
      ErrorDocument 501 http://www.domain.com/404.html
      ErrorDocument 503 http://www.domain.com/404.html


      copy this to a text file in the root of all domains/sub domains that you want to redirect 404 traffic from and rename it to .htaccess

      or do the same and just use the "ErrorDocument 404" line from above

      that should do it, or someone here will correct me

      Comment

      • EBORG9
        Confirmed User
        • Oct 2006
        • 1823

        #4
        I have this in my .htacess file:
        _____________________________________
        # BEGIN WordPress
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond &#37;{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
        </IfModule>

        # END WordPress
        __________________________________
        Where exactly would you put this, to make it function properly, before, or after?

        Comment

        • Myst
          Confirmed User
          • Feb 2004
          • 4708

          #5
          Originally posted by chris01282
          RewriteEngine On
          ErrorDocument 400 http://www.domain.com/404.html
          ErrorDocument 401 http://www.domain.com/404.html
          ErrorDocument 403 http://www.domain.com/404.html
          ErrorDocument 404 http://www.domain.com/404.html
          ErrorDocument 500 http://www.domain.com/404.html
          ErrorDocument 501 http://www.domain.com/404.html
          ErrorDocument 503 http://www.domain.com/404.html


          copy this to a text file in the root of all domains/sub domains that you want to redirect 404 traffic from and rename it to .htaccess

          or do the same and just use the "ErrorDocument 404" line from above

          that should do it, or someone here will correct me
          I tried it but it wont redirect all subdomains too..
          domain.com/* -> 404.html works
          *.domain.com/ -> doesnt
          ICQ: 298-523-037

          Comment

          • borked
            Totally Borked
            • Feb 2005
            • 6284

            #6
            Originally posted by EBORG9
            I have this in my .htacess file:
            Code:
            <IfModule mod_rewrite.c>
            RewriteEngine On
            
            [b]ErrorDocument 404 http://www.domain.com/404.html[/b]
            
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]
            </IfModule>

            For coding work - hit me up on andy // borkedcoder // com
            (consider figuring out the email as test #1)



            All models are wrong, but some are useful. George E.P. Box. p202

            Comment

            • SmokeyTheBear
              ►SouthOfHeaven
              • Jun 2004
              • 28609

              #7
              you need to setup wildcard subdomains
              hatisblack at yahoo.com

              Comment

              • SmokeyTheBear
                ►SouthOfHeaven
                • Jun 2004
                • 28609

                #8
                depending on your hoist its prob not setup that way by default so you will likely need to ask your host to setup wildcard subs
                hatisblack at yahoo.com

                Comment

                • EBORG9
                  Confirmed User
                  • Oct 2006
                  • 1823

                  #9
                  Originally posted by borked
                  Code:
                  <IfModule mod_rewrite.c>
                  RewriteEngine On
                  
                  [b]ErrorDocument 404 http://www.domain.com/404.html[/b]
                  
                  RewriteBase /
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule . /index.php [L]
                  </IfModule>
                  Excellent. Thanks.

                  Comment

                  • ssp
                    Confirmed User
                    • Jan 2005
                    • 7990

                    #10
                    I don't think the mod rewrite solution is the correct solution as it parses the headers as 200 instead of 404. This might look ok the the surfer but is technically incorrect and search engines won't like it much.

                    Correct me if I'm wrong.

                    Comment

                    Working...