2013-02-13 143 views
1

我在我的网络服务器上安装了一个CodeIgniter项目(http://sample.org/myproject/)。.htaccess无法正常工作

对于CodeIgniter的路由规则(例如index.php/controller/methode)我在使用RewriteEngine的myproject文件夹中编写了一个.htaccess文件。该文件是建立如下:

AuthType Basic 
AuthUserFile /home/www/myuser/html/myproject/.htpasswd01 
AuthName "secured area" 
require valid-user 
Options -Indexes 
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

现在的问题我已经得到了:如果我把正常的页面(http://sample.org/myproject/index.php/somestuff),它工作正常,但在现阶段,我只能直接调用该目录(http://sample.org/myproject/),这只会工作一些特定的时间。有时它会起作用(在显示此错误的特定时间之后),有时它不起作用。

这是否与浏览器重新读取.htaccess的时间有关?

+0

尝试改变'重写规则*的index.php/$ 0 PT,L]''要重写规则^ $的index.php/$ 1 [ PT,L]' – 2013-02-13 07:30:01

+0

myproject其实是您的$ DOCUMENT_ROOT下的一个真实目录? – anubhava 2013-02-13 08:50:51

+0

@anubhava是的,这是一个现有的.htaccess-File文件夹。 – 2013-02-13 08:56:03

回答

0

由于myproject实际上是在你的$DOCUMENT_ROOT一个真正的目录,你有RewriteCond %{REQUEST_FILENAME} !-d在你的.htaccess(也就是说,如果要求不是一个目录执行),因此您的重写规则甚至没有开火。

这个替换现有代码:(。*)

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule . index.php/$0 [NC,L]