我正在使用 Kohana Framework 3.x。我的网络服务器是 Apache,我使用虚拟主机,因为我用我的服务器管理多个网站。
我的 httpd.conf 看起来像这样:
<VirtualHost *:80>
ServerName www.myPage1.com
ServerAlias myPage1.com
DocumentRoot /var/www/myPage1
</VirtualHost>
<VirtualHost *:80>
ServerName www.myPage2.com
ServerAlias myPage2.de
DocumentRoot /var/www/myPage2
</VirtualHost>
在 Kohana 中,每个 http 请求都需要先转到 index.php。因为我不喜欢这些以 index.php 开头的丑陋 URL(例如 www.myPage1.com/index.php/item/detail/itemId),所以我使用了以下完美运行的 .htaccess 文件
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
我现在不想再使用 .htaccess 文件,而是将所有重写逻辑放入我的 httpd.conf 文件中。以下给了我一个“400 Bad Request”
<VirtualHost *:80>
RewriteEngine On
<Files .*>
Order Deny,Allow
Deny From All
</Files>
RewriteRule ^(?:aplication|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
ServerName www.myPage2.com
ServerAlias myPage2.com
DocumentRoot /var/www/myPage2
</VirtualHost>
我究竟做错了什么?帮助将不胜感激!