[英]404 page not found issue arise when htaccess change in codeigniter
htaccess代碼:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
配置文件:
$config['base_url'] = 'http://baseurl/apps';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['enable_hooks'] = FALSE;
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
我收到“找不到404頁”錯誤。 當我更改htaccess文件時
RewriteRule ^(.*)$ index.php?/$1 [L] to RewriteRule ^(.*)$ index.php/$1 [L]
出現“未指定輸入文件”錯誤。
我已經嘗試了幾種htaccess代碼,但仍然遇到這些問題。
我正在使用上面的htaccess代碼,從網址中刪除index.php。
尚不能使用評論,因此請使用答案框。 您可能想看一下這個問題,該問題已解決,並且看起來與您的問題幾乎完全相同: CodeIgniter htaccess和URL重寫問題
編輯:如果您使用的是nginx或其他Web服務器,請記住,這些服務器不支持.htaccess文件。 在某些應用程序中,有時我也會在Nginx中收到“未指定文件輸入”錯誤。 通常是因為這些服務器不支持.htaccess文件。 因此,請確保您正在使用Apache。
嘗試設定
RewriteBase /apps/
在您的.htaccess文件中
總的來說,我使用這個htaccess,它從不讓我失望:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.