.htaccess 与虚拟主机 zend 框架 1 ubuntu
.htaccess with virtual hosting zend framework 1 ubuntu
我已经设置了一个具有虚拟主机的 Ubuntu 服务器,在文件夹 :/var/www/vhosts/dev.blla.com/httpdocs/src
中是使用 zend framework 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
您的虚拟主机文件应如下所示。不要使用 location
指令,尤其是对 root /
。您应该使用 Directory
。
<VirtualHost dev.blla.com:80>
ServerName dev.blla.com
DocumentRoot /var/www/vhosts/dev.blla.com/httpdocs
<Directory "/var/www/vhosts/dev.blla.com/httpdocs">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Directory>
</VirtualHost>
这些是唯一的上下文 RewriteEngine
可以工作。 Location
不是其中之一。更改后重新启动 apache。
server config, virtual host, directory, .htaccess
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteengine
编辑: 显然你的 .htaccess 文件中有这个。这是行不通的。正如我上面提到的,这应该是您的虚拟主机文件。 .htaccess 中唯一允许的就是这个。 VirtualHost 和 Directory 可以不能用于 .htaccess。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这也可能对您有所帮助。
我已经设置了一个具有虚拟主机的 Ubuntu 服务器,在文件夹 :/var/www/vhosts/dev.blla.com/httpdocs/src
中是使用 zend framework 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
您的虚拟主机文件应如下所示。不要使用 location
指令,尤其是对 root /
。您应该使用 Directory
。
<VirtualHost dev.blla.com:80>
ServerName dev.blla.com
DocumentRoot /var/www/vhosts/dev.blla.com/httpdocs
<Directory "/var/www/vhosts/dev.blla.com/httpdocs">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Directory>
</VirtualHost>
这些是唯一的上下文 RewriteEngine
可以工作。 Location
不是其中之一。更改后重新启动 apache。
server config, virtual host, directory, .htaccess
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteengine
编辑: 显然你的 .htaccess 文件中有这个。这是行不通的。正如我上面提到的,这应该是您的虚拟主机文件。 .htaccess 中唯一允许的就是这个。 VirtualHost 和 Directory 可以不能用于 .htaccess。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这也可能对您有所帮助。