【问题标题】:Having trouble with mod_rewrite on my Laravel app在我的 Laravel 应用程序上遇到 mod_rewrite 问题
【发布时间】:2014-04-12 00:43:50
【问题描述】:

目前,我只能访问我的 Laravel 项目中的链接,如果它们是 domain.com/index.php/somepage 的形式。我希望能够使用domain.com/somepage 之类的 URL 进行访问。在我的本地 Windows 机器上,它工作正常。我的服务器在 Ubuntu 上并运行 Apache 2.4.6,rewrite 模块是通过a2enmod rewrite 启用的。我的 .htaccess 是 Laravel 附带的默认值:

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

    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]
</IfModule>

我还尝试了 Laravel 文档中的替代方法,无论是否使用 &lt;IfModule&gt;

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On

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

我意识到以前有人问过这个问题,但我似乎仍然可以将它与我见过的其他示例一起使用。我猜它一定是我没有设置的一些 Apache 配置。

【问题讨论】:

  • 你没有说出你想要什么而面临麻烦?
  • @SheikhHeera 谢谢,我把它加进去了。这个问题已经得到了回答。

标签: apache .htaccess mod-rewrite ubuntu laravel


【解决方案1】:

您是否确保 allowoverides all 在您的 httpd 配置中?

这听起来像你的问题。

【讨论】:

  • 就是这样。我刚刚在我的apache2.conf 文件中切换了相应目录中的设置。
猜你喜欢
  • 2021-04-14
  • 1970-01-01
  • 2022-01-24
  • 1970-01-01
  • 2021-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-14
相关资源
最近更新 更多