在codeigniter -htaccess中删除index.php [英] Removing index.php in codeigniter -htaccess
问题描述
我尝试从过去4天的网址中删除index.php,但未成功。
http://domainName.com/CI/index.php/controller-name/function/parameter
CI是godaddy中托管的文件夹。
/
.htaccess
CI
Google搜寻后,我尝试使用下列程式码,但只显示空白网页或错误:500,我也不明白逻辑。请有人帮我找到哪里出错。
RewriteEngine on
RewriteCond $ 1!^(index\。 php | [Javascript / CSS /图片根文件夹名称] | robots\.txt)
RewriteRule ^(。*)$ /index.php/$1 [L]
第二
RewriteEngine on
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule。* index.php / $ 0 [PT,L]
我还更改了CI / application / config / config.php
中的行
$ config ['index_page'] ='';
$ config ['uri_protocol'] =REQUEST_URI
解决方案按照以下步骤操作:
按如下方式更改配置文件:
$ config ['index_page'] ='';
$ b b$ config ['uri_protocol'] ='AUTO';
使用以下.htaccess:
RewriteEngine on
RewriteCond $ 1!^(index\.php | resources | robots\.txt)
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php / $ 1 [L,QSA]
注意:.htaccess因服务器而异。一些服务器(例如:Godaddy)需要使用以下.htaccess:
RewriteEngine on
RewriteCond $ 1!^ index\.php | resources | robots\.txt)
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index .php?/ $ 1 [L,QSA]
在base_url中使用以下代码:
$ config ['base_url'] ='http'。 ('isset($ _ SERVER ['HTTPS'])&& $ _SERVER ['HTTPS'] =='on')?''':'')。'://'.$_SERVER ['HTTP_HOST' ] .str_replace('//','/',dirname($ _ SERVER ['SCRIPT_NAME'])。'/');
Im trying to remove index.php from the url for the past 4 days but not successful.
http://domainName.com/CI/index.php/controller-name/function/parameter
CI is the folder hosted in godaddy.
/
.htaccess
CIAfter googling, I tried with the following codes but getting only a blank page or error:500 and also I didn't understand the logic. Please someone help me to find where Im going wrong.
RewriteEngine on RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
2nd
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L]
I also changed the line in, CI/application/config/config.php
$config['index_page'] = '';
$config['uri_protocol'] = "REQUEST_URI"
解决方案Follow the following step:
Change the config file like this:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Use the following .htaccess:
RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Note: .htaccess vary depending on server. Some server (e.g.: Godaddy) need to use the following .htaccess:
RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Use the following code in base_url:
$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['SCRIPT_NAME']).'/');
这篇关于在codeigniter -htaccess中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!