2016-02-12 198 views
1

我有一個angularJS站點,並且.htaccess文件已被配置爲將所有流量從mysite.se/*重定向到mysite.se/index.html。.htaccess:允許特定的URL

它還配置了prerender.io讓搜索引擎訪問該網站。

問題:我想添加一個博客到blog.mysite.se,問題當然是它會被重定向到mysite.se/index.html。我需要添加到.htaccess文件才能通過blog.mysite.se?

感謝

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^MYSITE\.se$ [NC] 
RewriteRule ^.*$ http://www.MYSITE.se%{REQUEST_URI} [R=301,L] 


# If requested resource exists as a file or directory 
# (REQUEST_FILENAME is only relative in virtualhost context, so not usable) 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d 
# Go to it as is 
RewriteRule^- [L] 

# If non existent 
# If path ends with/and is not just a single /, redirect to without the trailing/
RewriteCond %{REQUEST_URI} ^.*/$ 
RewriteCond %{REQUEST_URI} !^/$ 
RewriteRule ^(.*)/$ $1 [R,QSA,L]  

# Handle Prerender.io 
RequestHeader set X-Prerender-Token "kEJ0CC1gMnj6V0J4u8xu" 

RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR] 
RewriteCond %{QUERY_STRING} _escaped_fragment_ 

# Proxy the request 
RewriteRule ^(.*)$ http://service.prerender.io/http://%{HTTP_HOST}$1 [P,L] 

# If non existent 
# Accept everything on index.html 
RewriteRule^/index.html 

回答

1

插入此規則略低於RewriteEngine On從當前規則跳過blog子域名:

RewriteEngine On 

RewriteCond %{HTTP_HOST ^blog\. [NC] 
RewriteRule^- [L] 

# rest of rules here