我遇到了一些我无法弄清楚的麻烦。我老老实实地花了好几个小时试图找到解决方案,但我不知道发生了什么。
我有一个域domain.tld,它在我的服务器上的public_html文件夹中有各种文件。 我有一个子域名clients.domain.tld,它在public_html / clients /子文件夹中也有各种文件。
我的目标是让这两个目录彼此完全分开。我不希望人们能够通过domain.tld访问/ clients /子文件夹
由于某种原因,客户端子文件夹中的htaccess文件似乎是从根htaccess文件继承属性。
值得注意的是,"网站"设置为通过其各自基本文件夹的index.php处理所有请求。
我的问题:
domain.tld htaccess文件(位于public_html / .htaccess中):
SetEnvIfNoCase Referer ptr.cnsat.com.cn spammer=yes
SetEnvIfNoCase Via pinappleproxy spammer=yes
SetEnvIfNoCase Referer semalt.com spammer=yes
SetEnvIfNoCase Referer poker spammer=yes
Order allow,deny
Allow from all
Deny from env=spammer
Deny from ptr.cnsat.com.cn
Options +FollowSymlinks -MultiViews -Indexes
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|HTTrack|Yandex).*$ [NC]
RewriteRule .* - [F,L]
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# RedirectMatch ^/clients/(.*)$ https://clients.domain.tld/$1
# I tried this but it redirects requests in the form of
# "https://clients.domain.tld/clients/add" to
# "https://clients.domain.tld/add" which is no good!
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# from what I understand, !-d and !-f means exclude directories
# and exclude files, is there a way to say exclude /source/ for example?
RewriteRule ^.*$ ./index.php
clients.domain.tld htaccess文件(位于public_html / clients / .htaccess中):
Options +FollowSymlinks -MultiViews -Indexes
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|HTTrack|Yandex).*$ [NC]
RewriteRule .* - [F,L]
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
我非常感谢任何可以帮助我解决这些问题的人,我知道我一次要求很多事情,但我已经尝试了很多,我完全陷入困境。 非常感谢你的时间。