Question

I try to access a file via Ajax but all I get is an error 500.

I need access to the following file:

/templates/***/sections/popular.php

It works on localhost (MAMP) but when I uploaded my site to my server ajax stopped working.

The php error log is empty. Permission of the directories and file (see above) is 755. I use Hostgator.

This is my htaccess-file:

#ultimate htaccess-file
<Files .htaccess> 
order allow,deny 
deny from all 
</Files> 

AddDefaultCharset utf-8 
AddCharset utf-8 .html .css .js .xml .json .rss .atom 

#end ultimate htaccess-file




#prevent directory listing and redirect to 404-php
Options -Indexes 
ErrorDocument 403 /index.php







DirectoryIndex index.php

RewriteEngine on
RewriteBase /

RewriteRule ^cat/([0-9]+)?/([^/\.]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&page=$3 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+)/([0-9a-zA-Z?-]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&sortby=$3&page=$4 [L]

RewriteRule ^cat/([0-9]+)?/([^/\.]+)/([0-9a-zA-Z?-]+)-([0-9]+) index.php?task=category&id=$1&sortby=$3&page=$4 [L]

RewriteRule ^cat/([0-9]+)?/([^/\.]+) index.php?task=category&id=$1&name=$2 [L]
RewriteRule ^tag/([^/\.]+)/([0-9a-zA-Z?-]+)/([0-9]+) index.php?task=tag&t=$1&sortby=$2&page=$3 [L]
RewriteRule ^tag/([^/\.]+) index.php?task=tag&t=$1 [L]
RewriteRule ^profile/([0-9]+)?/([^/\.]+) index.php?task=profile&id=$1&name=$2 [L]
RewriteRule ^profile/comments/([0-9]+)?/([^/\.]+) index.php?task=users_comments&id=$1&name=$2 [L]
RewriteRule ^page/([0-9]+) index.php?task=view_page&id=$1 [L]  
#RewriteRule ^register index.php?task=register [L] 
RewriteRule ^lost-password index.php?task=lost_pass [L] 
RewriteRule ^links index.php?task=links [L]
RewriteRule ^news/item/([0-9]+)/([^/\.]+) index.php?task=news&id=$1 [L]
RewriteRule ^news/page([0-9]+) index.php?task=news&page=$1 [L]
RewriteRule ^members/([^/\.]+)-([^/\.]+)/page([0-9]+)? index.php?task=member_list&sort=$1&order=$2&page=$3 [L]
RewriteRule ^members index.php?task=member_list [L]
RewriteRule ^messages index.php?task=messages [L]
RewriteRule ^submit-game index.php?task=submit [L]
RewriteRule ^search/([^/\.]+) index.php?task=search&q=$1 [L]
RewriteRule ^search index.php?task=search [L]
RewriteRule ^friends index.php?task=friends [L]
RewriteRule ^submit index.php?task=submit [L]

RewriteRule ^newest-games.rss rss.php [L]

RewriteRule ^r-([0-9]+)?-([0-9]+)? go.php?id=$1&ref=$2 [L]
RewriteRule ^r-([0-9]+)? go.php?id=$1 [L]
RewriteRule ^([^/\.]+)/([0-9]+)/([^/\.]+) index.php?task=view&id=$2 [L]

RewriteRule ^news/([^/\.]+) index.php?task=news&name=$1 [L]
RewriteRule ^profile/([^/\.]+) index.php?task=profile&name=$1 [L]
RewriteRule ^news index.php?task=news [L]
RewriteRule ^page/([^/\.]+) index.php?task=view_page&name=$1 [L]  

RewriteRule ^forums/([^/\.]+)/([^/\.]+)/([0-9]+)?-newpost avforums/core/find_post.php?forum_name=$1&name=$2&topic_id=$3 [L]
RewriteRule ^forums/([^/\.]+)/([^/\.]+)/([0-9]+)?-findpost([0-9]+)? avforums/core/find_post.php?forum_name=$1&name=$2&topic_id=$3&post_id=$4 [L]
RewriteRule ^forums/([^/\.]+)/([^/\.]+)/([0-9]+) index.php?task=topic&forum_name=$1&name=$2&page=$3 [L]
RewriteRule ^forums/([^/\.]+)?/([0-9]+) index.php?task=forum&name=$1&page=$2 [L]
RewriteRule ^forums/([^/\.]+)/([^/\.]+) index.php?task=topic&forum_name=$1&name=$2 [L]
RewriteRule ^forums/([^/\.]+) index.php?task=forum&name=$1 [L]
RewriteRule ^forums index.php?task=forums [L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/([0-9a-zA-Z'?-]+)/([0-9]+) index.php?task=category&name=$1&sortby=$2&page=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/([^/\.]+) index.php?task=view&cat=$1&name=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+) index.php?task=category&name=$1 [L]






#ultimate htaccess-file
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]  
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]  
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]  
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]  
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]  
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]  
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]  
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]  
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]  
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]  
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]  
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]  
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]  
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]  
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]  
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]  
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]  
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]  
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]  
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]  
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]  
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]  
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]  
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]  
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]  
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]  
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]  
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]  
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]  
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]  
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]  
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]  
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]  
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]  
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]  
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]  
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]  
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]  
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]  
RewriteCond %{HTTP_USER_AGENT} ^Zeus  
RewriteRule ^.* - [F,L] 

SetEnvIfNoCase User-Agent "^libwww-perl*" block_bad_bots 
Deny from env=block_bad_bots 

    Header set X-UA-Compatible "IE=Edge,chrome=1" 
    # mod_headers can't match by content-type, but we don't want to send this header on *everything* 
    <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" > 
      Header unset X-UA-Compatible 
    </FilesMatch> 




<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$"> 

    Header set Access-Control-Allow-Origin "*" 

</FilesMatch> 


AddType application/javascript         js 

# Audio 
AddType audio/ogg                      oga ogg 
AddType audio/mp4                      m4a 

# Video 
AddType video/ogg                      ogv 
AddType video/mp4                      mp4 m4v 
AddType video/webm                     webm 

# SVG 
#   Required for svg webfonts on iPad 
#   twitter.com/FontSquirrel/status/14855840545 
AddType     image/svg+xml              svg svgz  
AddEncoding gzip                       svgz 

# Webfonts                              
AddType application/vnd.ms-fontobject  eot 
AddType application/x-font-ttf    ttf ttc 
AddType font/opentype                  otf 
AddType application/x-font-woff        woff 

# Assorted types                                       
AddType image/x-icon                   ico 
AddType image/webp                     webp 
AddType text/cache-manifest            appcache manifest 
AddType text/x-component               htc 
AddType application/x-chrome-extension crx 
AddType application/x-xpinstall        xpi 
AddType application/octet-stream       safariextz 
AddType text/x-vcard                   vcf 
AddType application/futuresplash       spl 
AddType application/x-shockwave-flash swf 
AddType application/vnd.android.package-archive apk 


  ExpiresActive on 

# Perhaps better to whitelist expires rules? Perhaps. 
  ExpiresDefault                          "access plus 1 month" 

# cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5) 
  ExpiresByType text/cache-manifest       "access plus 0 seconds" 



# Your document html 
  ExpiresByType text/html                 "access plus 0 seconds" 

# Data 
  ExpiresByType text/xml                  "access plus 0 seconds" 
  ExpiresByType application/xml           "access plus 0 seconds" 
  ExpiresByType application/json          "access plus 0 seconds" 

# RSS feed 
  ExpiresByType application/rss+xml       "access plus 1 hour" 

# Favicon (cannot be renamed) 
  ExpiresByType image/x-icon              "access plus 1 week"  

# Media: images, video, audio 
  ExpiresByType image/gif                 "access plus 1 month" 
  ExpiresByType image/png                 "access plus 1 month" 
  ExpiresByType image/jpg                 "access plus 1 month" 
  ExpiresByType image/jpeg                "access plus 1 month" 
  ExpiresByType video/ogg                 "access plus 1 month" 
  ExpiresByType audio/ogg                 "access plus 1 month" 
  ExpiresByType video/mp4                 "access plus 1 month" 
  ExpiresByType video/webm                "access plus 1 month" 

# HTC files  (css3pie) 
  ExpiresByType text/x-component          "access plus 1 month" 

# Webfonts 
  ExpiresByType font/truetype             "access plus 1 month" 
  ExpiresByType font/opentype             "access plus 1 month" 
  ExpiresByType application/x-font-woff   "access plus 1 month" 
  ExpiresByType image/svg+xml             "access plus 1 month" 
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month" 

# CSS and JavaScript 
  ExpiresByType text/css                  "access plus 1 year" 
  ExpiresByType application/javascript    "access plus 1 year" 
  ExpiresByType text/javascript           "access plus 1 year" 


    Header append Cache-Control "public" 



  Header unset ETag 

FileETag None 

    SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding 
    RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding 


  AddOutputFilterByType DEFLATE text/html text/plain text/css application/json 
  AddOutputFilterByType DEFLATE application/javascript 
  AddOutputFilterByType DEFLATE text/xml application/xml text/x-component 
  AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml 
  AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype  


  #end of ultimate htaccess-file

Update: The folder (* * *) above 'sections' has an .htaccess-file. This is the content:

<files ~ "\.php$">
order deny,allow
allow from none
deny from all
</files>

Solution

Apache was not able to execute an htaccess-file located in the 'sections'-folder. I just had to remove two colons after the IP-address of my site (initially I inserted them because of Google Chrome (localhost)).

Était-ce utile?

La solution

Try wrapping your directives in <IfModule> containers. That way, if a module isn't loaded, it won't cause a 500 server error.

For exmaple, starting from:

RewriteEngine on

all the way to:

RewriteRule ^.* - [F,L] 

Wrap that entire block of directives inbetween a:

<IfModule mod_rewrite.c>
# all your rewrite stuff goes in here
</IfModule>

And the same with any Header line, like:

Header set X-UA-Compatible "IE=Edge,chrome=1" 
# mod_headers can't match by content-type, but we don't want to send this header on *everything* 
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" > 
  Header unset X-UA-Compatible 
</FilesMatch> 

Can be wrapped:

<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=Edge,chrome=1" 
# mod_headers can't match by content-type, but we don't want to send this header on *everything* 
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" > 
  Header unset X-UA-Compatible 
</FilesMatch> 
</IfModule>

and all of your expires stuff, starting from:

ExpiresActive on

to

ExpiresByType text/javascript           "access plus 1 year" 

can be wrapped in:

<IfModule mod_expires.c>
# all your expires stuff goes here
</IfModule>

Then if you stop getting the 500 server error, make sure mod_expires, mod_headers and most importantly mod_rewrite is loaded. Though it would seem by default mod_rewrite is loaded on hostgator.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top