.htaccess:允许特定网址

时间:2016-02-12 14:12:16

标签: .htaccess server

我有一个angularJS网站,并且.htaccess文件已配置为将所有流量从mysite.se/*重定向到mysite.se/index.html。

它还配置了prerender.io,让搜索引擎访问该站点。

问题:我想在blog.mysite.se中添加一个博客,问题当然是将它重定向到mysite.se/index.html。我需要添加什么才能通过blog.mysite.se添加到.htaccess文件中?

由于

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 个答案:

答案 0 :(得分:1)

RewriteEngine On行下方插入此规则,以跳过当前规则中的blog子域名:

RewriteEngine On

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

# rest of rules here