2017-03-02 16 views
0

我正在使用prerender.io JavaScript中間件在我的網站上呈現JS頁面。從prerender htaccess重寫規則中刪除index.php

htaccess中間件代碼如下。

RewriteCond %{HTTP_USER_AGENT} googlebot|bing|msnbot|yandex|yahoo|baidu|facebook|screaming|siteliner|ahrefsbot|dmca.com [NC,OR] 
    RewriteCond %{QUERY_STRING} _escaped_fragment_ 
    RewriteCond %{HTTP:X-Prerender} !1 

    # Only proxy the request to Prerender if it's a request for HTML 
    RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.svg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/https://www.example.com/$2 [P,L] 

這個問題,我的服務器上至少(但不是在一些人)是index.php文件被添加到發送到服務,這會導致錯誤的URL。

EG:https://www.example.com/index.php

是否可以停止?

EG:https://www.example.com/

謝謝。

回答

0

首先,您不想通過用戶代理檢查googlebot,bingbot或yandex,因爲它們支持_escaped_fragment_抓取協議。通過他們的用戶代理檢查他們可能會讓你受到懲罰。

嘗試改變這一行:

RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.svg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/https://www.example.com/$2 [P,L] 

這樣:

RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.svg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(index.php)?(.*) http://service.prerender.io/https://www.example.com/$3 [P,L] 

通知加(的index.php)?並將$ 2更改爲$ 3。另外,不要忘記將www.example.com更改爲您的域名。