【问题标题】:htaccess - creating exception for the subdomainhtaccess - 为子域创建异常
【发布时间】:2015-11-22 00:05:03
【问题描述】:

我遇到了 htaccess 子域异常的问题。

我添加了下面的代码来为 uae.example.it 子域创建一个例外,该子域是一个受密码保护的目录。

RewriteCond %{HTTP_HOST} !uae\.example\.it 

但是我的浏览器没有提示我输入用户名和密码并显示:

禁止 “您无权访问此服务器上的 /。此外,一个 尝试使用 404 Not Found 错误 ErrorDocument 来处理请求。”

这是我的整个 htaccess 文件。我相信这是一个 .htaccess 相关问题。有什么建议吗?

Options -Indexes  
IndexIgnore *

RewriteEngine on

#########################################
# RIMUOVO WWW                           #
#########################################

RewriteCond %{HTTP_HOST} !uae\.example\.it
#RewriteCond %{HTTP_HOST} ^example.it$ [NC]
#RewriteRule ^(.*)$ http://example.it/$1 [R=301,L]


#########################################
# REDIRECT A SITO WEB                   #
#########################################

RewriteCond %{REQUEST_URI} !/abc0000/(.*)$
RewriteCond %{REQUEST_URI} !/abc2015/(.*)$
RewriteRule ^(.*)$ /abc2015/$1 [NC,L]


#########################################
# LANG                                  #
#########################################

#RewriteRule ^abc2015/it/(.*) abc2015/$1 [L]
#RewriteRule ^abc2015/en/(.*) abc2015/$1 [L]

#########################################
# SEO FRIENDLY URL                      #
#########################################

#RewriteRule ^abc2015/r-(.*)$ abc2015/index_exec.php?cmd=seo&fn=$1 [NC,L]
#RewriteRule ^abc2015/p-(.*)$ abc2015/$1.php [NC,L]

RewriteRule ^abc2015/en/$ abc2015/index.php [NC,L]
RewriteRule ^abc2015/it/$ abc2015/index.php [NC,L]

RewriteRule ^abc2015/en/our-company$ abc2015/company.php [NC,L]
RewriteRule ^abc2015/it/la-nostra-azienda$ abc2015/company.php [NC,L]

RewriteRule ^abc2015/en/sectors$ abc2015/sectors.php [NC,L]
RewriteRule ^abc2015/it/settori$ abc2015/sectors.php [NC,L]

RewriteRule ^abc2015/en/expertise$ abc2015/expertise.php [NC,L]
RewriteRule ^abc2015/it/competenze$ abc2015/expertise.php [NC,L]

RewriteRule ^abc2015/en/projects/(.*)$ abc2015/projects.php?fn=$1 [NC,L]
RewriteRule ^abc2015/it/progetti/(.*)$ abc2015/projects.php?fn=$1 [NC,L]

RewriteRule ^abc2015/en/project/(.*)$ abc2015/project.php?fn=$1 [NC,L]
RewriteRule ^abc2015/it/progetto/(.*)$ abc2015/project.php?fn=$1 [NC,L]

RewriteRule ^abc2015/en/contacts$ abc2015/contacts.php [NC,L]
RewriteRule ^abc2015/it/contatti$ abc2015/contacts.php [NC,L]

RewriteRule ^abc2015/en/privacy-policy$ abc2015/terms.php [NC,L]
RewriteRule ^abc2015/it/privacy-policy$ abc2015/terms.php [NC,L]

RewriteRule ^abc2015/en/careers$ abc2015/careers.php [NC,L]
RewriteRule ^abc2015/it/lavora-con-noi$ abc2015/careers.php [NC,L]


#########################################
# ERROR PAGES                           #
#########################################

#ErrorDocument 400 /abc2015/error.php?error=400
#ErrorDocument 401 /abc2015/error.php?error=401
#ErrorDocument 403 /abc2015/error.php?error=403
#ErrorDocument 404 /abc2015/error.php?error=404
#ErrorDocument 500 /abc2015/error.php?error=500

###
# SecFilterEngine Off
# SecFilterScanPOST Off
###

【问题讨论】:

    标签: apache .htaccess subdomain


    【解决方案1】:

    RewriteCond 仅用于下一个RewriteRule。
    如果你不想使用其他规则,uae.example.it在开头添加:

    RewriteCond %{HTTP_HOST} ^uae\.example\.it$
    RewriteRule ^ - [L]
    

    这意味着:什么都不做

    【讨论】:

    • 这删除了子域的异常,现在浏览器将我重定向到“abc2015/uae”。 @Croises
    • 您是否尝试过使用其他浏览器(缓存问题)。因为如果它是第一条规则,则此子域之后不会重定向
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 2020-04-16
    • 1970-01-01
    • 2011-10-28
    • 2016-06-11
    • 2010-10-09
    相关资源
    最近更新 更多