I need help for 404 error and .htaccess

Discussion in 'PHP' started by Md Nazmul Islam, Nov 16, 2013.

  1. #1
    Hello experts,

    I wrote code on .htaccess file for 404 error page. But this file now working properly. When I upload .htaccess file on directory my site show forbidden. Please help me to solve the problem. Here is the code and error page.
    http://www.whitehatseoteam.com/error404.html

    <Files ~ "^\.(htaccess)$">
    deny from all
    </Files>
    Options Indexes
    ErrorDocument 404 error404.html
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(whitehatseoteam\.com)(:80)? [NC]
    RewriteRule ^(.*) http://www.whitehatseoteam.com/$1 [R=301,L]
    DirectoryIndex index.html     
    Redirect permanent http://whitehatseoteam.com http://www.whitehatseoteam.com
    Redirect permanent https://www.whitehatseoteam.com http://www.whitehatseoteam.com
    Redirect permanent https://whitehatseoteam.com http://www.whitehatseoteam.com
    order deny,allow
    
    PHP:
     
    Md Nazmul Islam, Nov 16, 2013 IP
  2. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    <Files ~ "^\.(htaccess)$">
    deny from all
    </Files>
    Options Indexes
    ErrorDocument 404 /error404.html
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(whitehatseoteam\.com)(:80)? [NC]
    RewriteRule ^(.*) http://www.whitehatseoteam.com/$1 [R=301,L]
    DirectoryIndex index.html   
    Redirect permanent http://whitehatseoteam.com http://www.whitehatseoteam.com
    Redirect permanent https://www.whitehatseoteam.com http://www.whitehatseoteam.com
    Redirect permanent https://whitehatseoteam.com http://www.whitehatseoteam.com
    order deny,allow
    
    PHP:
    You missed out the slash after 'ErrorDocument 404' :)
     
    shivampaw, Nov 18, 2013 IP
  3. Md Nazmul Islam

    Md Nazmul Islam Active Member

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    63
    #3
    Thanks for reply. It's not working properly. When I upload the file .htaccess file on my server. My site show forbidden. I hope you will be help me to write current code.
     
    Md Nazmul Islam, Nov 19, 2013 IP
  4. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #4
    This line:
    
    ErrorDocument 404 error404.html
    
    Code (markup):
    should be:
    
    ErrorDocument 404 /error404.html
    
    Code (markup):
     
    rainborick, Nov 19, 2013 IP
  5. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    Thats Kind of what I said :(
    I am able to access your site fine, try getting rid of the unnecessary stuff on the .htaccess file then see if you can view your site. If you can just add each line one by one to identify the error, when you find it post back :)
     
    shivampaw, Nov 19, 2013 IP
  6. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Not tested so keep a backup of current code:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(whitehatseoteam\.com)(:80)? [NC]
    RewriteRule ^(.*) http://www.whitehatseoteam.com/$1 [R=301,L]
    
    # HTTPS REDIRECTION
    RewriteCond %{HTTPS}=on
    RewriteRule ^(.*)$ http://www.whitehatseoteam.com/$1 [R=301,L]
    
    ErrorDocument 404 /error404.html
    
    Options All -Indexes
    Code (markup):

    Try that and see how it goes :)
     
    shivampaw, Nov 19, 2013 IP
  7. Md Nazmul Islam

    Md Nazmul Islam Active Member

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    63
    #7
    I made correction, but same problem. When I put .htaccess file on root. My site show forbidden
     
    Md Nazmul Islam, Nov 20, 2013 IP
  8. Md Nazmul Islam

    Md Nazmul Islam Active Member

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    63
    #8
    It's not working .........
     
    Md Nazmul Islam, Nov 20, 2013 IP
  9. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #9
    I have a feeling you should contact your host in case you are on a blacklist for some reason - I am able to see your site fine is why I say this.

    Good Luck
     
    shivampaw, Nov 20, 2013 IP