![](/img/trans.png)
[英]laravel framework : is it safe to move index.php from public folder to the project root?
[英]CodeIgniter | Move index.php to public folder
我是CodeIgniter的新手,可以考慮嘗試一下
$config['base_url'] = 'http://localhost:8000';
php -S 0.0.0.0:3000
啟動服務器 一切順利。接下來,我嘗試將index.php
文件移動到公共文件夾中-那就是事情開始崩潰的時候。
使用以下代碼段創建了一個新文件public / .htaccess
RewriteEngine on RewriteCond $1 !^(index\\.php|assets|images|js|css|uploads|favicon.png) RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-d RewriteRule ^(.*)$ ./index.php/$1 [L]
修改后的$system_path = '../system';
和$application_folder = '../application'
; 在public/index.php
。
重新啟動服務器后嘗試訪問該頁面時,我得到404 Resource not found
。
您是否更改了服務器配置中的根文件夾?
如果將index.php移到另一個文件夾,則應該在服務器設置中將路徑更改為index.php。 在配置文件中。
這很簡單
$system_path = __DIR__ . '../system';
$application_folder = __DIR__ . '../application';
並使用正常的codeignitor .htacess文件,一切運行正常。 Symfony在index.php中也做同樣的事情。 當然,您的CSS,圖像,上傳文件夾應位於公用文件夾內。 然后您可以刪除所有index.html文件,
defined('BASEPATH') OR exit('No direct script access allowed');
聲明;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.