【问题标题】:Laravel Url Rewrite and avoid the public folderLaravel Url 重写并避免公用文件夹
【发布时间】:2016-09-23 03:01:01
【问题描述】:

我在我的 laravel 项目中的 public/.htaccess 文件中添加了以下内容。

#### Force lower case URL ####
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]

它可以将所有大写字符转换为小写字符,但是它将 url 重新路由到公用文件夹。

即。 /jobs 被重新路由到 /public/jobs

有办法避免这种情况吗?

【问题讨论】:

    标签: php .htaccess laravel


    【解决方案1】:

    你不应该编辑或添加.htaccess文件,编辑index.php等。你应该做的是point web server to a public directory instead of root one。

    如果您使用的是 Apache,请在虚拟主机块中编辑这些行:

    DocumentRoot "C:/projects/laravel/public"
    <Directory "C:/projects/laravel/public">
    

    重新启动 Apache,一切都会按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-23
      • 2015-04-24
      • 2020-03-30
      • 2011-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多