虚拟主机Apache2(Ubuntu 14.04)

我试图在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

所以如果我设置FollowSymLinks或SymLinksIfOwnerMatch,我会得到一个循环,如果我没有我的用户不能访问该目录。


如果它会有用,这是我的“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/

好吧,我解决了这个问题,在mysite.net/中将.htaccess从webmaster_home /
当我从前一个目录移动整个sito时,隐藏的文件不会与其他文件一起移动。

链接地址: http://www.djcxy.com/p/64215.html

上一篇: Virtual Host Apache2 (Ubuntu 14.04)

下一篇: Apache2: Change response headers