簡體   English   中英

從Xamp中的Codeigniter中刪除index.php

[英]Remove index.php from codeigniter in xamp

我已經嘗試了很多答案,但是一直遇到404恐怖高牆。 我在Windows 7上使用xamp堆棧。 mod_rewrite已啟用。

我將htaccess文件放在主“ codeigniter”目錄中,即包含應用程序,系統和user_guide的目錄。 我應該把它放在應用程序目錄下嗎? 一個帶有views / model / config / etc的視圖?

這是我當前的.htaccess文件:

RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/

RewriteBase /website/codeigniter/

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule .* index.php/$0 [PT] 

訪問http://localhost/website/codeigniter/index.php/welcome可以訪問http:// localhost / website / codeigniter / welcome不能

我的config.php有

$config['base_url'] = 'http://localhost/website/codeigniter/';
$config['index_page'] = '';

任何幫助,不勝感激!

錯誤是:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

Error 404

更新哦,剛想到要查看apache日志,得到此錯誤:

[Thu Mar 08 18:28:25 2012] [error] [client ::1] File does not exist: C:/xampp/htdocs/website/codeigniter/welcome

因此,似乎沒有采取適當的代碼點火器重定向? 不確定?

首先創建.htacess文件,然后將以下代碼粘貼到該RewriteEngine上

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

然后去配置文件

$config['index_page'] = 'index.php';

改成

$config['index_page'] = '';

享受

嘗試這個:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
$config['index_page'] = 'index.php';

改成

$config['index_page'] = '';

您是否在apache中啟用了mod_rewrite?

我一次又一次地遇到相同的錯誤,但是經過很少的研究,我找到了解決方案。

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /Codeigniter_start/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /Codeigniter_start/index.php/$1 [L,QSA] 

</IfModule>

重要的是the project folder 就像我使用RewriteBase /Codeigniter_start/RewriteRule ^(.*)$ /Codeigniter_start/index.php/$1 [L,QSA]

也可以從配置文件index_page更改,如下所示。

 $config['index_page'] = '';

希望這會有所幫助。

首先,在XAMPP中啟用Apache的“重寫模塊”

如果您使用的是XAMPP或WAMP軟件包,則可以在以下位置找到文件:

{xampp_dir}/apache/conf/httpd.conf
{wamp_dir}/apache/conf/httpd.conf

查找以下行並刪除“#”號。

LoadModule rewrite_module modules/mod_rewrite.so

實際上,我們可以通過XAMPP彈出菜單執行上層操作:Apache-> Apache Modules-> rewrite module,然后選擇它以啟用它。

其次,我們需要通過以下方式更改htaccess:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

嘗試將htaccess的最后一行更改為:

RewriteRule .* index.php/$1 [L] 

另外,嘗試將配置文件中的請求方法從AUTO更改為REQUEST_URI

暫無
暫無

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

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