我试图用.htaccess,CI 1.7.3和php 5.3隐藏index.php并得到错误404。 但它在我的开发服务器上工作正常,它有php 5.2,其余部分都是相同的配置,我使用HMVC和我的.htaccess开发了我的应用程序
RewriteEngine on
Options -Indexes
RewriteBase /myapp/
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /myapp/index.php?/$1 [L]
如果我升级CI版本,有人建议我如何解决这个问题?
由于
答案 0 :(得分:1)
尝试
RewriteEngine on
Options -Indexes
RewriteBase /myapp/
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
或者
RewriteEngine on
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ myapp/index.php?/$1 [L]
可能是您的.htaccess认为应该打开myapp/myapp/index.php
。
答案 1 :(得分:1)
从system / application / config目录打开config.php
并替换
$config['index_page'] = “index.php” by $config['index_page'] = “”
在CodeIgniter目录
的根目录中创建“.htaccess”文件并添加以下行。
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
在某些情况下,uri_protocol的默认设置无法正常工作。
要解决此问题,请更换
`$config['uri_protocol'] = “AUTO”`
通过
$config['uri_protocol'] = “REQUEST_URI”
from system / application / config / config.php
答案 2 :(得分:0)
您是否检查过您的服务器中是否包含您的apache重写模块,并在apache配置文件中启用了重写规则。