删除XAMPP apache服务器上的index.php?

时间:2011-07-08 14:16:31

标签: php .htaccess codeigniter

更新

好的,我已经从CI中的配置中删除了index.php引用,并且它不再出现在我的url字符串中。

当我输入我的基本网址时,它工作正常并显示我的主页:

http://localhost/midas/

然而,当我点击链接将我带到其他页面时,我现在找不到对象:

e.g。我点击Blog按钮,它将我带到:

http://localhost/midas/site/blog

我是否需要更改链接,因为index.php已被删除?

Apache错误日志***

Terminating on signal SIGTERM(15)
[Tue Jul 12 11:14:31 2011] [warn] pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Tue Jul 12 11:14:31 2011] [notice] Digest: generating secret for digest authentication ...
[Tue Jul 12 11:14:31 2011] [notice] Digest: done
[Tue Jul 12 11:14:33 2011] [notice] Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Tue Jul 12 11:14:33 2011] [notice] Server built: Oct 18 2010 01:58:12
[Tue Jul 12 11:14:33 2011] [notice] Parent: Created child process 3856
[Tue Jul 12 11:14:35 2011] [notice] Digest: generating secret for digest authentication ...
[Tue Jul 12 11:14:35 2011] [notice] Digest: done
[Tue Jul 12 11:14:36 2011] [notice] Child 3856: Child process is running
[Tue Jul 12 11:14:36 2011] [notice] Child 3856: Acquired the start mutex.
[Tue Jul 12 11:14:36 2011] [notice] Child 3856: Starting 150 worker threads.
[Tue Jul 12 11:14:36 2011] [notice] Child 3856: Starting thread to listen on port 443.
[Tue Jul 12 11:14:36 2011] [notice] Child 3856: Starting thread to listen on port 80.
[Tue Jul 12 13:02:00 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:02:09 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:02:24 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:02:34 2011] [error] [client 127.0.0.1] File does not exist:     C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:03:53 2011] [error] [client 127.0.0.1] File does not exist:     C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:03:56 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:04:52 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:06:13 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site
[Tue Jul 12 13:07:37 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site, referer: http://localhost/midas/
[Tue Jul 12 13:08:05 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/midas/site, referer: http://localhost/midas/

我的htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [NC,R=301,L]

3 个答案:

答案 0 :(得分:0)

-f和-d标志应该忽略任何不是文件或目录的内容......所以如果/ site / blog或者你正在访问的任何URL实际存在于请求根目录中,它可能正在尝试在不使用重写规则的情况下将请求路由到那里。

但是,当您尝试此配置时,了解您实际看到的行为会很有帮助。

答案 1 :(得分:0)

试试这个

 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ /index.php/$1 [NC,R=301,L]

答案 2 :(得分:0)

您使用重定向规则(R=301)是否有特殊原因?

如果您删除规则的该部分,那么您将获得[NC,L],然后保留隐藏网址。

我已经在我的Wamp Server安装上尝试了你的规则,它在我的工作正常,你是否肯定mod_rewrite为你开火?

相关问题