apache - mod 重写不适用于 laravel 和 bitNami

标签 apache mod-rewrite wamp laravel bitnami

http.conf 已取消注释 mod 重写

所以没有自定义路由起作用#laravel 中的某人提到这是因为 mod 重写在这里不起作用是我的设置:

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 

这是更可取的,但对于主要问题来说是次要的

公共(public)文件夹内的.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>

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

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

应该用

解决
http://localhost/laravel/test 

但是我收到了 404 错误

最佳答案

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 虚拟主机。

关于apache - mod 重写不适用于 laravel 和 bitNami,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14797206/

相关文章:

mysql - 负载均衡器和 SQL 备份

eclipse - Apache Tomcat 启动错误

php - Apache mod-rewrite 不接受查询字符串中的双引号

mod-rewrite - 对不同的文件夹使用重写

Windows 上的 PHP + LibPuzzle?

apache - 使用 solr DIH 时数据不匹配

apache - solrconfig.xml中的solr.data.dir相对指向哪里?

.htaccess - 网站 self 推荐

mysql - 将数据库从旧版本 wamp 恢复到新版本 wamp

apache - WAMP服务器无法上线