Htaccess文件给我HTTP错误500

时间:2015-09-23 18:38:28

标签: apache .htaccess

我试图写一个htaccess文件并让我的站点地图通过,所以他们不会被重新定向/重新编写。所以他们实际上是正确的网址,如果这是有道理的。这就是我到目前为止......

RewriteEngine on

RewriteRule ^ robots.txt - [L]

    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/sitemap_index.xml [OR]
    RewriteCond %{REQUEST_URI} ^/track-sitemap.xml
    RewriteRule ^(.*) /$1 [L]

    RewriteCond %{HTTP_USER_AGENT} facebookexternalhit/1.1|Facebot|Googlebot|bingbot|Googlebot-Mobile|Baiduspider|Yahoo|YahooSeeker|DoCoMo|Twitterbot|TweetmemeBot|Twikle|Netseer|Daumoa|SeznamBot|Ezooms|MSNBot|Exabot|MJ12bot|sogou\sspider|YandexBot|bitlybot|ia_archiver|proximic|spbot|ChangeDetection|NaverBot|MetaJobBot|magpie-crawler|Genieo\sWeb\sfilter|Qualidator.com\sBot|Woko|Vagabondo|360Spider|ExB\sLanguage\sCrawler|AddThis.com|aiHitBot|Spinn3r|BingPreview|GrapeshotCrawler|CareerBot|ZumBot|ShopWiki|bixocrawler|uMBot|sistrix|linkdexbot|AhrefsBot|archive.org_bot|SeoCheckBot|TurnitinBot|VoilaBot|SearchmetricsBot|Butterfly|Yahoo!|Plukkie|yacybot|trendictionbot|UASlinkChecker|Blekkobot|Wotbox|YioopBot|meanpathbot|TinEye|LuminateBot|FyberSpider|Infohelfer|linkdex.com|Curious\sGeorge|Fetch-Guess|ichiro|MojeekBot|SBSearch|WebThumbnail|socialbm_bot|SemrushBot|Vedma|alexa\ssite\saudit|SEOkicks-Robot|Browsershots|BLEXBot|woriobot|AMZNKAssocBot|Speedy|oBot|HostTracker|OpenWebSpider|WBSearchBot|FacebookExternalHit [NC,OR]
    RewriteCond %{QUERY_STRING} _escaped_fragment_=(.*)$
    RewriteRule ^(.*)$ /snapshots/$1? [NC,L]

    RewriteCond %{REQUEST_URI}  ^/$
    RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
    RewriteRule ^(.*)$ /snapshots/%1? [NC,L]

     RewriteCond %{REQUEST_FILENAME} -s [OR]
     RewriteCond %{REQUEST_FILENAME} -l [OR]
     RewriteCond %{REQUEST_FILENAME} -d
     RewriteRule ^.*$ - [NC,L]

     RewriteRule ^(.*) /index.php [NC,L]

2 个答案:

答案 0 :(得分:0)

最后一个RewriteRule将导致无限重定向。 添加一些RewriteCond,或者更好 - 删除它,因为它毫无意义。

答案 1 :(得分:0)

您的第一个站点地图规则导致无限循环:

RewriteCond %{REQUEST_URI} ^/sitemap_index.xml [OR]
RewriteCond %{REQUEST_URI} ^/track-sitemap.xml
RewriteRule ^(.*) /$1 [L]

因为它将站点地图网址重写为相同的网址。

将第一条规则更改为以下规则,以忽略网站地图网址的所有重写规则:

RewriteCond %{REQUEST_URI} ^/sitemap_index\.xml [OR]
RewriteCond %{REQUEST_URI} ^/track-sitemap\.xml
RewriteRule ^ - [L]