發佈日期: 發佈留言

Laravel php 去除 url 中的 public

簡單去除 url 中的 public

將 public 中的 index.php 複製一份

  • 將複製的 index.php,放到你要的資料夾位置。
    例如:原本的 url 是: www.domain.com/public,那 index.php 複製到 www.domain.com 資料夾之下。
  • 修改 index.php 如下,就完成囉:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/\ 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *