[英]CodeIgniter remove index.php from href
在CodeIgniter应用程序中
该链接有效
<a href="index.php/controller">link</a>
虽然这个不
<a href="controller">link</a>
配置有什么问题? 为了使链接在开始时没有“ index.php /”的情况下必须进行哪些更改?
这样做没有成功:
1)添加到application / routes.php
$route['(:any)'] = 'controller';
2)添加到application / .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>
3)在etc / apache2 / httpd.conf中未注释
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
首先,您应该将
$config['index_page'] = '';
在config config.php中,然后在放置在项目主目录中的.htaccess中编写以下代码。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
在您的.htaccess中使用它从网址中删除index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
您的链接应该是
<a href="/controller">link</a>
Config.php应该是
$config['index_page'] = '';
rewrite_module应该在apache中激活
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.