我怎样才能阻止我的.htaccess重定向我的子域主站点? [英] How can I stop my .htaccess redirecting my sub domain to main site?

查看:95
本文介绍了我怎样才能阻止我的.htaccess重定向我的子域主站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个htaccess的问题。基本上我的.htaccess被重定向我的新创建的子域名,主网站,我不希望它这样做。假设我的域名被称为www.beans.com'和子域是shop.beans.com,这是在pubic_html文件夹下的 /店/ 。这里是htaccess的:

I have a .htaccess question. Basically my .htaccess is redirecting my newly created sub domain, to the main site, and I don't want it to do so. Let's assume my domain is called 'www.beans.com', and the subdomain is 'shop.beans.com', which is in the pubic_html folder under /shop/. Here is the .htaccess:

DirectoryIndex index.php enmain.php

ErrorDocument 404 /404.html

## EXPIRES CACHING ##

ExpiresActive On
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/ico "access plus 1 year"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType text/xml "access plus 2 hours" 
ExpiresDefault "access plus 1 hour"

## EXPIRES CACHING ##

RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.beans.com$ [NC]
    RewriteRule ^(.*)$ http://www.beans.com/$1 [L,R=301]

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?|php)(\?[^\ ]*)?\ HTTP/
    RewriteRule ^(([^/]*/)*)index\.(html?|php)$  http://www.beans.com/$1  [R=301,L]
# Start CloudFlare:beans.com rewrite. Do not Edit 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^beans.com 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 
# End CloudFlare rewrite. 

因此​​,在总结,我想,当我浏览到shop.beans.com不被重定向到www.beans.com(它目前发生的事情)。

So in summary, I would like when I browse to 'shop.beans.com' not to be redirected to 'www.beans.com' (which it currently happening).

请好心人帮帮我:D

推荐答案

首先你有2个规则在做同样的事情,也就是加入 WWW。

First thing you have 2 rules doing same thing i.e. adding www..

1 - 删除这条规则:

1 - Delete this rule:

RewriteCond %{HTTP_HOST} !^www.beans.com$ [NC]
RewriteRule ^(.*)$ http://www.beans.com/$1 [L,R=301]

2 - 然后改变最后一条规则是这样的:

2 - Then change last rule like this:

RewriteCond %{HTTP_HOST} ^beans\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

这篇关于我怎样才能阻止我的.htaccess重定向我的子域主站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆