阿帕奇:虚拟主机和URL httpd.conf中的重写的Kohana框架 [英] Apache: Virtual Host and URL Rewriting inside httpd.conf for Kohana Framework
问题描述
我用Kohana的框架3.x的我的网络服务器是Apache和我使用虚拟主机,因为我和我的服务器管理多个网站。
I'm using the Kohana Framework 3.x. My Webserver is Apache and I use Virtual Hosts, because I manage more than one websites with my Server.
我的httpd.conf看起来是这样的:
My httpd.conf looks like this:
<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文件(例如www.myPage1.com/index.php/item/detail/itemId)我使用的完美工作以下.htaccess文件
In Kohana every http request needs to go to the index.php first. Because I dont like these ugly URLs that all starts with index.php (for example www.myPage1.com/index.php/item/detail/itemId) I used the following .htaccess file which worked perfectly
# 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错误的请求
I would now like to not use a .htaccess file anymore and instead put all the rewrite logic into my httpd.conf file. The following gives me a "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>
我是什么做错了吗?帮助将AP preciated!
What am I doing wrong? Help would be appreciated!
推荐答案
您不必在httpd.conf一个的RewriteBase。什么是错的。htaccess的?
You don't have a RewriteBase in your httpd.conf. And what's wrong with the .htaccess?
这篇关于阿帕奇:虚拟主机和URL httpd.conf中的重写的Kohana框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!