我的CodeIgniter项目中有两个控制器。 - home.php - dashboard.php
出于某种原因,当我将其更改为此时,我的htaccess使dashboard.php无效:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L] # THIS LINE HERE
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
但是,当我将其更改为下面的代码时,home.php不可用。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] # THIS LINE HERE
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
我不明白为什么,任何人都知道为什么会这样做?
谢谢, 斯科特
答案 0 :(得分:0)
试试这些:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteBase /ci_intro
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
将控制器home.php设为类Home扩展CI_Controller 并将其重命名为 Home.php 与dashboard.php相同