亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在默認 var/www/html 文件夾內的實時服務器中,如果沒有 index.php

在默認 var/www/html 文件夾內的實時服務器中,如果沒有 index.php

PHP
桃花長相依 2022-07-09 16:41:15
Codeigniter 路由在本地服務器中工作。當我部署到var/www/html服務器時,路由無法按預期工作。當我index.php在 URL 中添加控制器名稱之前,它工作正常。但沒有index.php,它會拋出 404 page not found 錯誤.htaccess文件RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php?/$1 [L]我也試過這個<IfModule mod_rewrite.c>    RewriteEngine On    RewriteBase /var/www/html/    RewriteRule ^index\.php$ - [L]    RewriteCond %{REQUEST_FILENAME} !-f    RewriteCond %{REQUEST_FILENAME} !-d    RewriteRule . /index.php [L]</IfModule>但沒有任何效果..
查看完整描述

3 回答

?
天涯盡頭無女友

TA貢獻1831條經驗 獲得超9個贊

您的服務器中似乎未啟用 mod_rewrite。如果重寫規則不起作用,請確保您在 Apache 配置文件中允許 .htaccess 文件。目錄部分應包含 AllowOverride All 選項:


<Directory "/var/www/html">

   Options Indexes FollowSymLinks

   AllowOverride All

   Order allow,deny

   Allow from all

</Directory>

不要忘記對 Apache 配置文件的任何更改都需要重新啟動服務!


查看完整回答
反對 回復 2022-07-09
?
鳳凰求蠱

TA貢獻1825條經驗 獲得超4個贊

嘗試以下解決方案:


轉到 application\config\config.php 文件


做出改變


$config['index_page'] = 'index.php';


$config['index_page'] = '';

.htaccess


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /YourCIFolderName/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /YourCIFolderName/index.php [L]

</IfModule>


查看完整回答
反對 回復 2022-07-09
?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

步驟1


去 application/config/config.php 找到


$config['index_page'] = 'index.php';

change it to

$config['index_page'] = '';

第2步


轉到 application/config/routes.php


評論結束后從頁面底部刪除所有內容并粘貼以下代碼


$route['default_controller'] = 'main'; // main is your default controller name

$route['404_override'] = '';

$route['translate_uri_dashes'] = FALSE;

$route['(:any)'] = "main/$1";

$route['admin'] = 'admin/login';

第 3 步


在根文件夾中添加一個名為 .htaccess 的新文件,其中包含名為 application 和 system 等的文件夾


添加以下代碼并打開網站


 RewriteEngine On

RewriteBase /

Options All -Indexes

RewriteCond %{REQUEST_METHOD} POST [NC]

RewriteRule ^ - [L]

<IfModule mod_rewrite.c>

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

</IfModule>


# remove index.php

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{THE_REQUEST} /index\.php [NC]

RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]

RewriteRule ^ %1 [L,R=301,NE]


# To externally redirect /dir/file.php to /dir/file

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]

RewriteRule ^ /%1 [R=301,NE,L]


# To internally forward /dir/file to /dir/file.php

RewriteCond %{DOCUMENT_ROOT}/$1.php -f

RewriteRule ^(.+?)/?$ $1.php [L]


Header set Access-Control-Allow-Origin "*"


RewriteEngine on

RewriteCond $1 !^(index\.php|resources|robots\.txt)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 


查看完整回答
反對 回復 2022-07-09
  • 3 回答
  • 0 關注
  • 253 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號