【问题标题】:Virtual Host Apache2 (Ubuntu 14.04)虚拟主机 Apache2 (Ubuntu 14.04)
【发布时间】:2015-01-19 03:10:25
【问题描述】:

我正在尝试在 apache2 上设置 VH,所以我创建了文件 "mysite.conf" 像这样

<Virtual Host *:80>
    ServerName mysite.net
    ServerAlias www.mysite.net
    ServerAdmin webmaster@mysite.net
    DocumentRoot /var/www/webmaster_home

    ErrorLog [...]
    CustomLog [...]
</VirtualHost>

一切正常,直到我决定将我的网站移动到一个名为 “mysite.net” 的新目录中。所以我修改了我的“mysite.conf”

<Virtual Host *:80>
    ServerName mysite.net
    ServerAlias www.mysite.net
    ServerAdmin webmaster@mysite.net
    DocumentRoot /var/www/webmaster_home/mysite.net

    ErrorLog [...]
    CustomLog [...]
</VirtualHost>

我的网站停止工作。日志文件报告:

AH00124: Request exceeded the limit of 10 internal redirects due to probable    configuartion error. Use 'LimitInternalRecursion' to increase the limit if    necessary. Use 'LogLevel debug' to get a backtrace.
AH00121: r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /var/www/webmaster_home/index.php  
AH00122: redirected from r->uri = /index.php  

在谷歌搜索我的问题后,我的 “mysite.conf” 出现错误,其中应包括:

<Directory />
        Options FollowSymLinks
        AllowOverride All
</Directory>
<Directory /var/www/webmaster_home>
        Options -Indexes -FollowSymLinks +MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>

完成了,我又试了一次,出现了一个新的错误报告

You don't have permission to access / on this server.

并查看它报告的日志文件:

AH00670: Options FollowSymLinks and SymLinksIfOwnerMatch are bot off, so the  
RewriteRule directive is also forbidden due to its similar ability to   
circumvent directory restrictions

所以如果我设置 FollowSymLinksSymLinksIfOwnerMatch 我会得到一个循环,如果我不这样做,我的用户将无法访问该目录。


如果有用的话,这是我的"apache2.conf"

<Directory />
    Options FollowSymLink
    AllowOverride None
</Directory>

<Directory var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

还有我的 /var/www/webmaster_home/.htaccess

<ifModule mod_rewrite.c>
    <ifModule mod_negotiation.c>
        Options -MultiViews
    </ifModule>

    RewriteEngine On

    ##
    ## You may need to uncomment the following line for some hosting enviroments,  
    ## if you have installed to a subdirectory, enter the name here also.
    ##
    # RewriteBase /

    ##
    ## Black liste protected files
    ##
    RewriteRule themes/.*/(layouts|pages|partials)/.*.htm index.php [L,NC]
    RewriteRule uploads/protected/.* index.php [L,NC]

    ##
    ## White listed folders and files
    ##
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} !\.js
    RewriteCond %{REQUEST_URI} !\.ico
    RewriteCond %{REQUEST_URI} !\.jpg
    RewriteCond %{REQUEST_URI} !\.jpeg
    RewriteCond %{REQUEST_URI} !\.gif
    RewriteCond %{REQUEST_URI} !\.css
    RewriteCond %{REQUEST_URI} !\.less
    RewriteCond %{REQUEST_URI} !\.scss
    RewriteCond %{REQUEST_URI} !\.pdf
    RewriteCond %{REQUEST_URI} !\.png
    RewriteCond %{REQUEST_URI} !\.swf
    RewriteCond %{REQUEST_URI} !\.txt
    RewriteCond %{REQUEST_URI} !\.xml
    RewriteCond %{REQUEST_URI} !\.xls
    RewriteCond %{REQUEST_URI} !\.eot
    RewriteCond %{REQUEST_URI} !\.woff
    RewriteCond %{REQUEST_URI} !\.ttf
    RewriteCond %{REQUEST_URI} !\.svg
    RewriteCond %{REQUEST_URI} !\.wmv
    RewriteCond %{REQUEST_URI} !\.avi
    RewriteCond %{REQUEST_URI} !\.mov
    RewriteCond %{REQUEST_URI} !\.mp4
    RewriteCond %{REQUEST_URI} !\.webm
    RewriteCond %{REQUEST_URI} !\.ogg
    RewriteCond %{REQUEST_URI} !docs/.*
    RewriteCond %{REQUEST_URI} !themes/.*
    RewriteCOnd ^ index.php [L,NC]

    ##
    ## Standard routes
    ##
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</ifModule>

这是我的目录树:

/var
|----www/
     |----webmaster_home/
          |----mysite.net/
          |----logs/

【问题讨论】:

    标签: apache2


    【解决方案1】:

    好吧,我通过从 webmaster_home/ 移动 mysite.net/ 中的 .htaccess 解决了这个问题
    当我从以前的目录移动整个站点时,隐藏文件没有与其余文件一起移动。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      • 2023-03-04
      • 2017-05-23
      • 1970-01-01
      • 2019-01-01
      • 2014-10-29
      • 2015-03-24
      相关资源
      最近更新 更多