用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4517|回复: 6
收起左侧

在config里去掉index.php,修改了htaccess,正确,但是还有其他问题

[复制链接]
发表于 2013-5-23 17:47:11 | 显示全部楼层 |阅读模式
在config里去掉index.php,修改了htaccess,正确,但是还有问题:

问题一:在URL里输入带index.php 还是能访问,如果我不想让加了index.php 来成功访问的话?我应该怎么改?

问题二:如果我想把index.php 换成 比如: hello.php 的话,如何修改?

以上问题我都在config 和 htaccess 反复测试,貌似都不对! 我改如何解决?
发表于 2013-5-23 22:26:11 | 显示全部楼层
本帖最后由 qi_ruo 于 2013-5-23 22:27 编辑

第一个应该不行吧
第二个可以把index.php文件名改为hello.php 再修改下.htaccess文件中的RewriteRule ^(.*)$ index.php/$1 [L]改为RewriteRule ^(.*)$ hello.php/$1 [L]
 楼主| 发表于 2013-5-23 23:01:40 | 显示全部楼层
按照你的方法,先修改了htaccess ,然后重新启动了apache ,再访问的时候,提示:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


--------------------------------------------------------------------------------

Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 Server at localhost Port 80
发表于 2013-5-24 08:40:37 | 显示全部楼层
访问首页可能有点问题,可以在.htaccess中添加DirectoryIndex hello.php
 楼主| 发表于 2013-5-24 10:07:36 | 显示全部楼层
RewriteEngine on
DirectoryIndex hello.php
RewriteCond $1 !^(index\.php|images|robots\.txt)   
RewriteRule ^(.*)$ hello.php/$1 [L]

这个是我的htaccess 现在的内容,然后重新启动apache ,再访问,还是500错误;
然后,我保持以上的修改内容, 再在$config['index_page'] = “hello.php”;,然后再重新启动apache ,还是500错误
发表于 2013-5-24 15:17:47 | 显示全部楼层
第一个也是可以的。集成一个通用的controller,然后在__construct中检测$_SERVER['REQUEST_URI']是否含有index.php即可。
至于问题二,按照 @qi_ruo 的方法去做肯定可行的,应该是你的 .htaccess 写错了,缺少RewriteBase项目或其他原因吧。
发表于 2013-5-29 22:19:59 | 显示全部楼层
支持楼上,重写控制器

本版积分规则