修改.htaccess以获取codeigniter URLS

时间:2014-06-27 10:04:15

标签: .htaccess codeigniter-2

我正在尝试从codeigniter中的url中删除index.php。重写mod脚本到处都是,但我找不到.htaccess文件!我试着查看根目录和其他地方,但没有运气。

从我读到的它应该是在应用程序文件夹中,当我去那里时,我发现.htaccess文件,所有它都是拒绝所有。这与其他人在修改之前在线共享的内容不同。

请指教。

2 个答案:

答案 0 :(得分:0)

其实你找不到;你使用index.php文件创建它,并带有以下内容:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
  

在上面的示例中,除了index.php之外的任何HTTP请求,   images和robots.txt被视为对index.php的请求   文件。

Reference

答案 1 :(得分:0)

解决方案如下(供将来参考)

在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]

打开config.php并更改index = "index.php" to ""。事情现在应该有效。