虚拟主机Apache2(Ubuntu 14.04)

时间:2015-01-19 03:10:25

标签: apache2

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

并且所有工作都很好,直到我决定将我的网站移动到名为&#34; mysite.net&#34; 的新目录中。所以我修改了我的&#34; mysite.conf&#34;

<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  

在谷歌搜索我的问题后,它会导致我的&#34; mysite.conf&#34; 出错,其中应包括:

<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 ,我会得到一个循环,如果我的用户无法访问该目录。


如果有用,这是我的&#34; apache2.conf&#34;

<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/

1 个答案:

答案 0 :(得分:0)

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