[英]CodeIgniter .htaccess - 500 Internal Server Error/ index.php remove
[英]CodeIgniter .htaccess remove index.php on Server
我知道這里有很多問題和答案,但我真的很困惑,還無法解決問題。 請幫忙!
我可以通過以下網址輕松訪問我的控制器:
http://www.example.com/new/index.php/welcome
但我無法通過以下網址獲取它: http : //www.example.com/new/welcome
我在子目錄“ new”中配置我的CodeIgniter站點,在我的服務器上,我的目錄結構是:
/
htdocs
new
/(這是空的),htdocs(這是我的目錄,名為“new”和new(這是我的codeIgniter文件的確切文件夾。我在這里對“/”和“htdocs”感到困惑,我認為這是我無法處理的事情,因為我的域example.com指向htdocs,即,如果將index.php放在htdocs中,則example.com將加載index.php。
我在“新”目錄中的.htaccess文件是:
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
在config / config.php中:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
我試過$config['uri_protocol']
為“Auto”,“REQUEST_URI”和“QUERY_STRING”等。
使用此配置,我可以刪除本地主機中的index.php,但我無法在服務器上修復它。 請幫忙!! 提前致謝。
將此代碼放在new
目錄中的.htaccess
文件中
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
並且不要忘記從以下位置刪除空格:
$config['index_page'] = ' ';
在.htaccess中嘗試使用此代碼:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
嘗試改變
$config['uri_protocol'] = 'PATH_INFO';`
或者更改重寫規則以使用查詢字符串:
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$1
然后將協議設置為查詢字符串:
$config['uri_protocol'] = 'QUERY_STRING';`
如果你說它在localhost上運行,那么它可能是服務器問題。 通過編寫phpinfo();
檢查服務器mod_rewrite是否打開phpinfo();
視圖代碼中的某個位置。 如果它未啟用且您沒有權限,請與您的主機管理員聯系。
這段代碼適合我:
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.php
$config['index_page'] = '';
這個對我有用
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
確保從appliation / config / config.php中刪除index.php
$config['index_page'] = '';
嘗試添加? 在htaccess中的index.php之后,
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.