2013-12-23 77 views
1

訪問文件我嘗試通過Ajax訪問一個文件,但我得到的是一個錯誤500 :(無法通過AJAX(錯誤500)

我需要訪問以下文件:

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

它可以在本地主機(毫安),但是當我上傳我的網站到我的服務器AJAX停止工作。

的PHP錯誤日誌是空的。的目錄和文件(見上文)的權限是755.我使用HostGator的。

An你幫忙嗎?

這是我的htaccess的文件:

#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:[email protected] [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 

更新:文件夾(* * *)上面的 '節' 有一個.htaccess文件。這是內容:

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

解決方案:阿帕奇無法執行位於「sections'文件夾一個htaccess文件。我只需在我的網站的IP地址後刪除兩個冒號(最初由於Google Chrome(本地主機)而插入了它們)。

+1

關於500錯誤的詳細信息保存在服務器的錯誤日誌中。首先看看有什麼問題。請注意,這是一個來自php的單獨日誌 - 如果這是一個htaccess問題,請求將在php有機會啓動之前被殺死。 –

+0

謝謝。我會檢查出來的。 – drpelz

+0

相信與否,但錯誤日誌是空的。 cPanel中有一個錯誤日誌,它是空的。 – drpelz

回答

1

嘗試在<IfModule>容器中包裝您的指令。這樣,如果一個模塊沒有加載,它不會導致500服務器錯誤。

對於〔實施例,起價:

RewriteEngine on 

一路:

RewriteRule ^.* - [F,L] 

裹指令,使整個區塊其間的一個:

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

與任何同Header一行,如:

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 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> 

和您的所有過期的東西,從開始:

ExpiresActive on 

ExpiresByType text/javascript   "access plus 1 year" 

可以包裹在:

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

然後,如果你停止得到500服務器錯誤,請確保mod_expires,mod_headers,最重要的是加載mod_rewrite 。雖然默認情況下mod_rewrite 在hostgator上加載的是

+0

好的提示。到目前爲止還不知道。非常感謝你。但我發現文件夾'節'不可見Hostgator(=不可訪問),我不知道這種奇怪行爲的原因... – drpelz

+1

你有一個「部分」文件夾中的htaccess文件? –

+0

是的,但它是空的。看看我更新的問題。 'sections'文件夾(***)上方有一個htaccess。它阻止所有直接訪問php文件(由於安全原因)。有什麼方法可以繞過它嗎? – drpelz