无法在MAC OSX上使用Codeigniter从网址中删除index.php [英] Cannot remove index.php from urls using Codeigniter on MAC OSX

查看:58
本文介绍了无法在MAC OSX上使用Codeigniter从网址中删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚购买了带有Mavericks 10.9.1的Mac-pro,在此之前,我正在Windows 7上运行PC.

I just bought a Mac-pro with Mavericks 10.9.1 and before that I was working on pc with Windows 7.

我在Windows 7 OS下创建了一个项目,现在我想将其导入OSX,除.htaccess文件外,导入成功.我无法从网址中删除 index.php .我已经安装了MAMP,并且只有在使用 index.php :

I created a project under the windows 7 OS and now I want to import it to OSX, the import was successful apart from the .htaccess file. I can't remove index.php from my urls. I have MAMP installed and my urls only work if I use index.php:

  • 不起作用:(localhost/〜username/feel/products)
  • 工作:(localhost/〜用户名/feel/index.php/products)

我尝试了.htaccess文件中RewriteEngine,RewriteCond和RewriteRule的所有选项.我给所有的文件夹/文件chmod 755,将 $ config ['base_url'] ='' $ config ['index_page'] =''; 没有root或index.php页面.

I tried all the options of RewriteEngine, RewriteCond and RewriteRule in .htaccess file. I give all the folders/files chmod 755, have put $config['base_url']='' and $config['index_page'] = ''; with and without root or index.php page.

.htaccess文件位于index.php页面的同一文件夹中,"AllowOverride None"是"AllowOverride All".

The file .htaccess is in the same folder of the index.php page, the AllowOverride None is AllowOverride All.

推荐答案

我认为问题与OS X处理apache的不同用户的方式有关.我按照 CodeIgniter URL文档中所述使用了.htaccess文件,并添加了使用RewriteBase的一行.

I think the problem is related to the way OS X handles different users for apache. I used the .htaccess file as described in the CodeIgniter URL documentation and added a line using RewriteBase.

RewriteEngine on
RewriteBase /~username/path/to/CI/
RewriteCond $1 !^(index\.php|static|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

顺便说一句,我正在使用OS X 10.9.3(Mavericks)和CodeIgniter 2.2.0

By the way, I'm using OS X 10.9.3 (Mavericks) and CodeIgniter 2.2.0

这篇关于无法在MAC OSX上使用Codeigniter从网址中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆