簡體   English   中英

在 XAMPP apache 服務器上刪除 index.php?

[英]Remove index.php on XAMPP apache server?

更新:

好的,我已經從 CI 的配置中刪除了 index.php 引用,它不再出現在我的 url 字符串中。

當我輸入我的基礎 url 時,它工作正常並顯示我的主頁:

http://localhost/midas/

但是,當我單擊將我帶到其他頁面的鏈接時,我現在得到 Object 未找到:

例如,我單擊博客按鈕,它帶我到:

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]

-f 和 -d 標志應該忽略不是文件或目錄的任何內容......因此,如果 /site/blog 或您正在訪問的任何 URL 實際存在於請求根目錄中,它可能會嘗試路由在不使用您的重寫規則的情況下請求那里。

不過,了解您在嘗試此配置時實際看到的行為會很有幫助。

嘗試這個

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

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

如果您刪除規則的該部分以便得到[NC,L] ,那么您將保留 url 的隱藏。

我已經在我的 Wamp 服務器安裝上嘗試了你的規則,它在我的上運行良好,你確定 mod_rewrite 正在為你觸發嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM