我的CodeIgniter项目在我的XAMPP系统上成功运行,url为
http://localhost/newsfeeds/users/allCategories/
当我把这个项目移动到另一个系统上,在Ubuntu 13.10上有LAMP服务器。要运行相同的页面,我需要url
http://localhost/newsfeeds/index.php/users/allCategories/
我需要index.php文件,否则它会显示一个页面不查找错误。
我的htaccess文件是,RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
如何在WAMPP和XAMP服务器上运行没有index.php的相同项目?
我找到了解决这个问题的方法。
在我的服务器中,模式重写已经开启。但是需要在/etc/apache2/apache2.conf
文件上更改一些默认值。以下是我的修改
首先找到
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
并将AllowOverride None更改为All并保存
然后使用命令启用模式重写(在本例中已经启用),
$ sudo a2enmod rewrite
然后重新启动服务器,
$ sudo /etc/init.d/apache2 restart
运行项目。没问题。
试试这个:
RewriteEngine on
RewriteCond $1 !^(index'.php|resources|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]