我在Windows上编写了我的Web应用程序,我将它推送到运行Ubuntu Linux的服务器上。这是我的.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /SearchDatGifUbuntu/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
我在/ etc / apache2 / sites-available / default的文件如下:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
我在我的ubuntu服务器上的命令行输入了sudo a2enmod rewrite,它说mod_rewrite已经打开了。
当我通过我的codeigniter应用程序调试时,错误似乎出现在CodeIgniter.php的第308行,即:
$CI = new $class();
有人可以告诉我发生了什么事吗?
答案 0 :(得分:3)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
试试这个.htaccess代码,然后重启你的apache
如果这不起作用,请尝试此链接
答案 1 :(得分:0)
我必须编辑:
/etc/apache2/apache2.conf中
并设置:
<Directory /var/www/html>
# ... other directives...
AllowOverride All
</Directory>
然后重启apache,以便读取上面的.htaccess代码。
答案 2 :(得分:0)
在CI项目文件夹中创建一个.htaccess文件。 在文件中输入以下代码。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]