1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.htaccess problem

Discussion in 'Apache' started by daredashi, Nov 8, 2005.

  1. #1
    Hi,

    i have problem with .htaccess redirection problem

    the file is

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [QSA,L]
    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>


    now problem is with 404 pages. for invalid urls also it redirects to my homepage. and it shows respoce as 200.

    any one can help me out to get actual 404 responce instead of 200
     
    daredashi, Nov 8, 2005 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    If you're only trying to redirect dead URLs...

    ErrorDocument 404 /whatever.html
     
    Nintendo, Nov 8, 2005 IP
  3. daredashi

    daredashi Well-Known Member

    Messages:
    667
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    120
    #3
    i don't want to redirect 404 pages at all. i want normal 404 browser responce for thos url.

    e.g.

    http://www.cyborginfo.com/sghfghjsdf

    this shows my home page

    i want normal 404 page can be display in place of that.
     
    daredashi, Nov 8, 2005 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    I'm not sure if that redirects or shows the content from that page. Change whatever.html to anything and try that out. If that doesn't do it, I don't know what the code is for it.
     
    Nintendo, Nov 8, 2005 IP
  5. daredashi

    daredashi Well-Known Member

    Messages:
    667
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    120
    #5
    thanks for the help Nintendo .

    if i redirect it to another.html still i wil receive 200 as responce.
    google site map or any search engin bots have problems with this kind of false responce.
    i want redirects except 404. i am unsure how i can exclude 404 redirects from above code.
     
    daredashi, Nov 8, 2005 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    I'm not even sure what 200 is. Try different numbers in the code.
     
    Nintendo, Nov 8, 2005 IP
  7. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #7
    generate a custom 404 that also sends you an e-mail.
    (you could use a second homepage with a noindex in it)

    refine the inital redirect to capture what it should do

    a 301 to a 404 is not uncommon - but keep it to a minimum as it may be seen as s**m

    The emails will tell you which pages to look at.

    I would not generally redirect to index (or home) as it maybe hard to find problems on your site once this is in. I use a second homepage with noindex to capture this if I have to redirect to the equivalent of home but also put in a simple mail so I know which requests cause poblems.


    Expat
     
    expat, Nov 8, 2005 IP
  8. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The problem is that your RewriteConds will redirect any file which doesn't exist to your index page - and these are exactly the files that should return a 404 error.

    Remove
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [QSA,L]
    Code (markup):
    from your .htaccess and replace with
    ErrorDocument 404 /404.html
    Code (markup):
    Then create the file 404.html telling the user that the page they were after couldn't be found. This will return the correct 404 error in the HTTP header.

    If you just want visitors to see the index page if the file couldn't be found, use
    ErrorDocument 404 /index.php
    Code (markup):
    The correct 404 header will still be returned.

    Nintendo, 200 is "OK" status code in HTTP

    cheers

    johnt
     
    johnt, Nov 9, 2005 IP
  9. daredashi

    daredashi Well-Known Member

    Messages:
    667
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    120
    #9
    thanks for your help Johnt.

    i think i am not provideing enough of details. i am sorry for incomplete that.

    i am using david's phplinkdirectory script for my directory.
    this script entirely works on .htaccess redirection rule. and back end mysql bakend (david, correct me if i am wrong)

    if i remove any of existing line script don't work properly.
    so i am looking for solution that will go along with existing code.
     
    daredashi, Nov 10, 2005 IP
  10. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ah, I see. In that case, you can't accomplish 404 errors by using your .htaccess file. What you will have to do is edit the script so that if it doesn't find the correct entry in the database it returns a 404 header. This can be done by using output buffering and
    header("HTTP/1.0 404 Not Found");
    PHP:
    Hope this helps

    John
     
    johnt, Nov 10, 2005 IP
  11. daredashi

    daredashi Well-Known Member

    Messages:
    667
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    120
    #11
    i will give a try.

    PHP coding is not my baby. i am not programmer. :(

    thanks once again to show way out john
     
    daredashi, Nov 10, 2005 IP