Codeigniter 如何从url中删除index.php
当我将鼠标移到锚定链接上或单击锚定链接时,它会显示Codeigniter 如何从url中删除index.php,codeigniter,url,Codeigniter,Url,当我将鼠标移到锚定链接上或单击锚定链接时,它会显示 http://localhost/code-testing/index.php/about-us. 我也尝试了base_url()和site_url(),但结果是一样的。如何从url中删除“index.php” -谢谢 已解决: 谢谢大家友好的回答。我用的是xampp,这个对我很有用 代码测试/application/config/config.php $config['base_url']= 'http://localhost/code-
http://localhost/code-testing/index.php/about-us.
我也尝试了base_url()和site_url(),但结果是一样的。如何从url中删除“index.php”
-谢谢
已解决:
谢谢大家友好的回答。我用的是xampp,这个对我很有用
代码测试/application/config/config.php
$config['base_url']= 'http://localhost/code-testing/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
代码测试/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
下面的链接没有在url中显示'index.php'
<li><a href="<?php echo base_url('home');?>">HOME</a></li>
<li><a href="<?php echo base_url('about_us');?>">About Us</a></li>
<li><a href="<?php echo base_url('contact');?>">Contact Us</a></li>
将变量设置为空,如下所示
$config['index_page'] = '';
$config['index_page'] = '';
尝试用这些参数逐个替换以下变量('AUTO'、'PATH\u INFO'、'QUERY\u STRING'、'REQUEST\u URI'和'ORIG\u PATH\u INFO')
$config['uri_protocol'] = 'AUTO';
$config['uri_protocol'] = 'AUTO';
将变量设置为空,如下所示
$config['index_page'] = '';
$config['index_page'] = '';
尝试用这些参数逐个替换以下变量('AUTO'、'PATH\u INFO'、'QUERY\u STRING'、'REQUEST\u URI'和'ORIG\u PATH\u INFO')
$config['uri_protocol'] = 'AUTO';
$config['uri_protocol'] = 'AUTO';
将.htaccess文件与index.php文件一起放在应用程序根目录中。(检查htaccess扩展是否正确,Bz htaccess.txt对我不起作用。) 并将以下规则添加到.htaccess文件中
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
然后在application/config/config.php文件中找到以下行
$config['index_page'] = 'index.php';
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
将变量设置为空,如下所示
$config['index_page'] = '';
$config['index_page'] = '';
就是这样,对我来说很有效
如果不起作用,请尝试用这些参数逐个替换以下变量(“自动”、“路径信息”、“查询字符串”、“请求URI”和“原始路径信息”)
$config['uri_protocol'] = 'AUTO';
$config['uri_protocol'] = 'AUTO';
将.htaccess文件与index.php文件一起放在应用程序根目录中。(检查htaccess扩展是否正确,Bz htaccess.txt对我不起作用。) 并将以下规则添加到.htaccess文件中
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
然后在application/config/config.php文件中找到以下行
$config['index_page'] = 'index.php';
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
将变量设置为空,如下所示
$config['index_page'] = '';
$config['index_page'] = '';
就是这样,对我来说很有效
如果不起作用,请尝试用这些参数逐个替换以下变量(“自动”、“路径信息”、“查询字符串”、“请求URI”和“原始路径信息”)
$config['uri_protocol'] = 'AUTO';
$config['uri_protocol'] = 'AUTO';
删除index.php有3个步骤 1.在application/config.php文件中进行以下更改
$config['index_page'] = 'index.php';
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
2.使用下面的代码在根目录中创建.htacces文件
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
3.启用重写模式
一,。首先,使用以下命令启动它:
a2enmod重写
二,。编辑文件/etc/apache2/sites enabled/000默认值
将AllowOverride None更改为AllowOverride All
iii.使用以下命令重新启动服务器:
sudo/etc/init.d/apache2重新启动删除index.php有3个步骤 1.在application/config.php文件中进行以下更改
$config['index_page'] = 'index.php';
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
2.使用下面的代码在根目录中创建.htacces文件
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
3.启用重写模式
一,。首先,使用以下命令启动它:
a2enmod重写
二,。编辑文件/etc/apache2/sites enabled/000默认值
将AllowOverride None更改为AllowOverride All
iii.使用以下命令重新启动服务器:
sudo/etc/init.d/apache2重启谢谢您的回答。您的解决方案也很有效。@user1844626:欢迎光临,谢谢您的回答。您的解决方案也起作用了。@user1844626:欢迎您,但很抱歉,这篇文章没有给出完整的解决方法。因为没有说$config['uri_protocol']='?'应该写什么;在config.php中,所以我没有得到这一点。但很抱歉,这篇文章没有给出实现这一点的全部方法。因为没有说$config['uri_protocol']='?'应该写什么;在config.php中,所以我没有得到它。