.htaccess masters, Help needed.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freecartoonporn
    Confirmed User
    • Jan 2012
    • 7683

    #1

    .htaccess masters, Help needed.

    hi all.,

    how do i do this .,

    i want to redirect all error/non existed pages to home page but not using

    errodocumnet 404 thing

    as it would show 404 in header.,

    rather i want header to show
    301 redirect.

    how do i do that ?

    so if i check header for nonexisted page link
    like www.blahblah.com/nonexisted.html

    it should thorw

    HTTP/1.1 301 Moved Permanently

    in header.


    thanks for your time.
    SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean
  • - Jesus Christ -
    Confirmed User
    • Mar 2003
    • 7197

    #2
    gfy "webmaster forum" lol
    2 seconds on Google gets what you need

    http://www.htaccessredirect.net/index.php

    Amen

    Comment

    • freecartoonporn
      Confirmed User
      • Jan 2012
      • 7683

      #3
      Originally posted by - Jesus Christ -
      gfy "webmaster forum" lol
      2 seconds on Google gets what you need

      http://www.htaccessredirect.net/index.php
      seriously?

      You didnt read my post.
      or am i missing something here ?
      SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

      Comment

      • David Petters
        Registered User
        • Jul 2012
        • 47

        #4
        ErrorDocument 404 /index.php
        My porn site

        Comment

        • AdultKing
          Raise Your Weapon
          • Jun 2003
          • 15601

          #5
          You might as well use 404, as redirecting many pages back to the home page with 301 will give you no SEO benefit. The idea is to redirect individual old pages to individual new pages, unless you do that the SEO benefit is null.

          If you really want to throw a 301 for every page you don't have on your site then do it in Perl or PHP using the guide here:

          http://www.seoworkers.com/seo-articl...tml#modrewrite

          Comment

          • - Jesus Christ -
            Confirmed User
            • Mar 2003
            • 7197

            #6
            Originally posted by freecartoonporn
            seriously?

            You didnt read my post.
            or am i missing something here ?
            I misunderstood becasue you're asking how to do something that is a very bad idea and should not be done, but here's how to redirect if a file does not exist...


            Code:
            # If requested resource exists as a file or directory, skip next rule
            RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
            RewriteCond %{DOCUMENT_ROOT}/$1 -d
            RewriteRule (.*) - [S=1]
            #
            # Else rewrite requests for non-existent resources to /index.php
            RewriteRule (.*) /index.php [R=302,L]

            I hacked someone else's code so double check it. I also made it 302 becasue 301 is a really really stupid idea in this situation.

            Amen

            Comment

            Working...