2015-06-23 15:25
浏览 46


I have a Laravel install that is using the standard .htaccess file, which works great for dev.mysite.com but on my dev server I have foo.dev.mysite.com and another route which is bar.dev.mysite.com

The routing is working fine, but the requests are not being rewritten to index.php, for example when I go to foo.dev.mysite.com/example I get a 404 but when I go to foo.dev.mysite.com/index.php?example it's working fine.

I have the following .htaccess file:

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

图片转代码服务由CSDN问答提供 功能建议

我有一个使用标准 .htaccess 文件的Laravel安装,效果很好 对于 dev.mysite.com ,但在我的开发服务器上,我有 foo.dev.mysite.com 和另一条路径 bar.dev.mysite.com < / code>

路由工作正常,但请求没有被重写到index.php,例如当我转到 foo.dev.mysite.com/example时 我得到了404,但是当我去 foo.dev.mysite.com/index.php?example 时它工作正常。

我有 以下 .htaccess 文件:

 &lt; IfModule mod_rewrite.c&gt; 
&lt; IfModule mod_negotiation.c&gt; 
  &lt; / IfModule&gt; 
 RewriteEngine On 
#Redirect Trailing Slash ... 
 RewriteRule ^(。*)/ $ / $ 1 [L,R = 301] 
#句柄前端控制器。  .. 
 RewriteRule ^ inde  x.php [L] 
&lt; / IfModule&gt; 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyejun1983 2015-06-23 17:21

    First, make sure mode_rewrite is enabled. I am sure you have probably done this but I want to make sure nothing is missed. Another test is to remove the IfModule condition and see if it fails.

    Next, see what version of apache you are running since the syntax has changed between 2.2 and 2.4. The Optons default was changed from All to FollowSymlinks in 2.3.11. This should not be a big deal and doubt this is the culprit but could be and save you trouble in the future.

    Next, try putting the rewrite condition inside of the vhost information instead of the htaccess file. This can help a little with performance as well as give you a console warn/err when restarting apache where the htaccess errors could be squelched.

    <directory /var/www/mysite.com>
        Options -MultiViews
        AllowOverride ALL
        RewriteEngine On
        RewriteRule ^(.*)/$ /$1 [L,R=301]
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php [QSA,L]

    Beyond this point I would be at a loss without some more logging or information from the server. You can also add CustomLog into the vhost and report all requests processed by the server.

    解决 无用
    打赏 举报

相关推荐 更多相似问题