Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess阻止子目录访问_Php_Apache_.htaccess_Mod Rewrite_Drupal - Fatal编程技术网

Php .htaccess阻止子目录访问

Php .htaccess阻止子目录访问,php,apache,.htaccess,mod-rewrite,drupal,Php,Apache,.htaccess,Mod Rewrite,Drupal,我有一个drupal站点,我需要得到第二个站点,它完全用html/css/js编码。我为第二个站点创建了一个文件夹和指向它的子域。但是,.htaccess文件在尝试访问子域时导致403禁止错误。如果我将文件删除或重命名为.htaccess.old,子网站将正常工作,但drupal网站不会。我的意思是,主页加载,但所有链接重定向到404未找到 我对.htaccess几乎一无所知,也不知道如何排除故障 以下是文件: # # Apache/PHP/Drupal settings: # # Prote

我有一个drupal站点,我需要得到第二个站点,它完全用html/css/js编码。我为第二个站点创建了一个文件夹和指向它的子域。但是,.htaccess文件在尝试访问子域时导致403禁止错误。如果我将文件删除或重命名为.htaccess.old,子网站将正常工作,但drupal网站不会。我的意思是,主页加载,但所有链接重定向到404未找到

我对.htaccess几乎一无所知,也不知道如何排除故障

以下是文件:

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.


# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  # There is no end quote below, for compatibility with Apache 1.3.
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0

</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{THE_REQUEST} /thelivingeffect [NC]
  RewriteRule ^ - [L]

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
#
#Apache/PHP/Drupal设置:
#
#保护文件和目录免受窥探。
#不显示映射到目录的URL的目录列表。
选项-索引
#遵循此目录中的符号链接。
选项+FollowSymLinks
#让Drupal处理任何404错误。
ErrorDocument 404/index.php
#对不存在的favicon.ico请求强制发送简单错误消息。
#为了与Apache1.3兼容,下面没有结束语。
ErrorDocument 404“未找到请求的文件favicon.ico。
#设置默认处理程序。
DirectoryIndex.php
#覆盖PHP设置。更多信息,请访问sites/default/settings.PHP
#但在运行时无法更改以下内容。
#PHP4,Apache1。
php\u值魔法\u引号\u gpc 0
php\u值寄存器\u全局0
php_值session.auto_启动0
php_值mbstring.http_输入传递
php_值mbstring.http_输出过程
php_值mbstring.encoding_翻译0
#PHP4,Apache2。
php\u值魔法\u引号\u gpc 0
php\u值寄存器\u全局0
php_值session.auto_启动0
php_值mbstring.http_输入传递
php_值mbstring.http_输出过程
php_值mbstring.encoding_翻译0
#PHP5、Apache1和Apache2。
php\u值魔法\u引号\u gpc 0
php\u值寄存器\u全局0
php_值session.auto_启动0
php_值mbstring.http_输入传递
php_值mbstring.http_输出过程
php_值mbstring.encoding_翻译0
#需要启用mod_expires。
#启用过期。
过期于
#访问后将所有文件缓存2周(A)。
到期默认A1209600
#不允许缓存PHP脚本,除非它们显式地发送缓存
#标题本身。否则所有脚本都必须覆盖
#如果mod_设置的头需要另一个缓存行为,则会过期。这可能会导致
#如果在引导过程的早期出现错误,则失败,并可能导致
#如果在子目录中安装了非Drupal PHP文件,则会出现问题。
过期活动关闭
#各种重写规则。
重新启动发动机
RewriteCond%{THE_REQUEST}/thelivingeffect[NC]
重写规则^-[L]
#如果您的站点既可以使用“www.”前缀访问,也可以不使用“www.”前缀访问,则您可以
#可以使用以下设置之一将用户重定向到您的首选
#URL,带或不带“www.”前缀。请仅选择一个选项:
#
#要重定向所有用户以访问带有“www.”前缀的网站,
# (http://example.com/... 将被重定向到http://www.example.com/...)
#调整和取消注释以下内容:
#RewriteCond%{HTTP_HOST}^example\.com$[NC]
#重写规则^(.*)$http://www.example.com/$1[L,R=301]
#
#要重定向所有用户以访问不带“www.”前缀的站点,
# (http://www.example.com/... 将被重定向到http://example.com/...)
#取消注释并调整以下内容:
#RewriteCond%{HTTP_HOST}^www\.example\.com$[NC]
#重写规则^(.*)$http://example.com/$1[L,R=301]
#如果在子目录或子目录中使用Drupal,请修改RewriteBase
#VirtualDocumentRoot和重写规则无法正常工作。
#例如,如果您的站点位于http://example.com/drupal 取消注释和
#修改以下行:
#重写BASE/drupal
#
#如果您的站点在以下位置的VirtualDocumentRoot中运行:http://example.com/,
#取消对以下行的注释:
#重写基/
#将表单“x”的URL重写为表单“index.php?q=x”。
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
RewriteCond%{REQUEST_URI}!=/favicon.ico
重写规则^(.*)$index.php?q=$1[L,QSA]

编辑:用于尝试访问子文件夹的url是www.thelivingeffect.mysite.com

就在行上的
重写引擎下方添加此行以跳过子文件夹以获取当前的任何重写规则。htaccess:

RewriteCond %{HTTP_HOST} ^thelivingeffect\. [NC,OR]
RewriteCond %{THE_REQUEST} /thelivingeffect [NC]
RewriteRule ^ - [L]

也许是我,但在这句话中,你有一个很难拼写的错误:

ErrorDocument 404 "The requested file favicon.ico was not found.
你没有关闭引号,之后的一切都是404错误,这可能就是发生的事情