[英]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.