【发布时间】:2015-06-22 17:26:25
【问题描述】:
我已经设置了一个具有虚拟主机的 Ubuntu 服务器,在文件夹 :/var/www/vhosts/dev.blla.com/httpdocs/src 中是使用 zend 框架 1 构建的 Web 应用程序。
问题是我有一个如下所示的 .htaccess 文件:
<VirtualHost dev.blla.com:80>
ServerName dev.blla.com
DocumentRoot /var/www/vhosts/dev.blla.com/httpdocs
RewriteEngine off
<Location />
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Location>
</VirtualHost>
.htacess 文件位于/var/www/vhosts/dev.blla.com/httpdocs,网络显示500 Internal Server Error 我做错了什么?
在错误日志中我有这一行:/var/www/vhosts/dev.blla.com/httpdocs/.htaccess: <VirtualHost not allowed here, referer: http://dev.blla.com/
虚拟主机文件:
<VirtualHost *:7080>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
【问题讨论】:
-
检查以确保您已为 apache 启用 Rewrite 模块
-
a2enmod rewrite 检查是否启用,返回 Module rewrite already enabled
-
尝试删除显示 RewriteEngine Off 的行,以确保。否则尝试更简单的重写。类似
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [NC,L] -
我删除了 RewriteEngine 关闭相同的结果。我应该把以下内容放在哪里: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [NC,L]
-
是的,我们需要更多关于您的设置的详细信息。如果您收到 Nginx 和 apache 错误,您可能正在使用代理服务或专门设置
标签: php apache .htaccess zend-framework virtual-hosts