2013-02-10 23 views
4

http.conf中有国防部重写注释掉国防部重写不laravel和bitNami工作

所以没有定制路由正在有人在#laravel提到这将是因为国防部重写没有在这里工作是我的设置:

laravel.conf具有下面的代码:

Alias /laravel/ "C:\BitNami/frameworks/laravel/public/" 
Alias /laravel "C:\BitNami/frameworks/laravel/public" 

<Directory "C:\BitNami/frameworks/laravel/public"> 
Options +MultiViews 
AllowOverride None 
<IfVersion <2.3> 
Order allow,deny 
Allow from all 
</IfVersion> 
<IfVersion >= 2.3> 
Require all granted 
</IfVersion> 
</Directory> 

如果我取消这些行:

#RewriteEngine On 
#RewriteRule ^/$ /laravel/ [PT] 

则主路线将映射到

http://localhost/ 

而非

http://localhost/laravel 

这是优选的,但次要的主要问题

htaccess的公共文件夹内具有这样的:

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
RewriteEngine On 
RewriteBase /laravel 
</IfModule> 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

这里是我在route.php中的测试代码:

Route::get('test',function(){ 
return 'test worked'; 
}); 

应与

http://localhost/laravel/test 

解决,而是我得到一个404错误

+0

有同样的问题,不知道如何解决它在Windows下... – Andy 2014-02-17 22:30:08

回答

0

RewriteBase和RewriteEngine叙述被定义两次。使您的.htaccess文件如下所示:

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine On 
    RewriteBase /laravel 
</IfModule> 

<IfModule mod_rewrite.c> 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

如果可能,最好使用Apache虚拟主机代替。

+0

我有同样的想法,和这个职位之前,删除那些行,但我有同样的问题,我已经复制并粘贴你的答案到laravel公共文件夹中的.htaccess,但唉,我仍然有问题,如原来的帖子 – arcanine 2013-02-10 13:22:43

+0

中所述我将如何去添加一个Apache虚拟主机? – arcanine 2013-02-10 13:23:55

+0

我从来没有使用BitNami,只注意到.htaccess文件中的重复。当我运行Windows时,我使用了[WampServer](http://www.wampserver.com/en/)。您将不得不编辑httpd-vhosts.conf文件并添加新的站点信息。通常有一个例子。然后在您的Windows主机文件(c:\ Windows \ System32 \ drivers \ etc \ hosts)中添加 '127.0.0.1 example.com' – Codeplus 2013-02-10 15:56:14

0

你的.htaccess文件应该是这样的。

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 

    # Redirect Trailing Slashes...  
    RewriteRule ^(.*)$ public/$1 [L] 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule>