gpt4 book ai didi

.htaccess - 如何停止.htaccess将子域重定向到主站点?

转载 作者:行者123 更新时间:2023-12-04 07:00:55 25 4
gpt4 key购买 nike

我有一个.htaccess问题。基本上,我的.htaccess会将我新创建的子域重定向到主站点,但我不希望这样做。假设我的域名为“ www.beans.com”,子域为“ shop.beans.com”,该域位于public_html下的/shop/文件夹中。这是.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”(当前正在发生)。

我该怎么做?

最佳答案

首先,您有2条规则执行相同的操作,即添加www.

1-删除此规则:

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


2-然后更改最后一条规则,如下所示:

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

关于.htaccess - 如何停止.htaccess将子域重定向到主站点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19306226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com