2013-06-24 40 views
2

我使用CentOS的刪除索引,笨不能從URL

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond $1 !^(index\.php|robots\.txt|resources) 
RewriteRule ^(.*)$ index.php/$1 [L] 
RewriteBase /var/www/html/site/ 

</IfModule> 

但歌廳同樣的問題,我用的index.php頁面工作正常,但當我的index.php刪除 它不工作...

+0

是'WWW'您的網站的根文件夾? – bottleboot

+1

你的rewritebase是錯誤的,它是相對於文檔根目錄 如果你的doc根目錄是/ var/www/html /你的rewritebase應該是/ site – ikhsan

+0

@ikhsan yes我以同樣的方式,如果不行這是不正確 – bottleboot

回答

6

我認爲它會幫助你,因爲我使用這一個。把這個代碼放到你的根文件夾的htaccess文件中。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

請讓我知道它是否工作與否。

+0

感謝這對我有用 –

+0

很高興它幫助你。 – ABorty

+1

謝謝親愛的Aritra –

0

config.php文件簡單的在你config文件夾搜索索引網址(index_page),並使其空

$config['index_page'] = ''; 
+0

是的,我有同樣的,我的config.php,但不能再工作 –

+0

你要麼改變配置文件或更改在htaccess .....不要互相混淆 – Gautam3164

+1

$ config ['index_page'] ='';這是這樣的,我的.htaccess是我寫在我的問題.. –

2

這可能是幾THI NGS。

1(從您的配置文件中刪除索引頁面(應用程序/配置/ config.php文件)

$config['index_page'] = ''; 

2(你有BASE_URL這樣的:

$config['base_url'] = 'http://yourdomain.com/'; 

注意/在最終

3(試試這個的.htaccess:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ index.php?/$1 [L] 

RewriteCond %{REQUEST_URI} ^LoginTut.* 
RewriteRule ^(.*)$ index.php?/$1 [L] 

RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha) 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [L] 
</IfModule> 
<IfModule !mod_rewrite.c> 
ErrorDocument 404 index.php 
</IfModule> 
+0

我已經嘗試相同的烏爾指導,但stell當我想我的網頁與index.php它需要我到谷歌,不工作 –

+0

什麼是你的網站?我可以看看嗎? –

+0

你不是在運行本地主機和Safari嗎? – tyrhus

0

試試這個對我有用ccnd是我的文件夾。

RewriteEngine on 
RewriteCond $1 !^(index\.php|uploads|images|css|js|lib|img|bootstrap|robots\.txt) 
RewriteRule ^(.*)$ /ccnd/index.php/$1 [L] 
0
RewriteEngine On 
RewriteBase /site_root/ 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 

重要提示:1, 必須設置在config.php文件$config['index_page'] = '';。 2. site_root是類似的文件夾名稱,wamp/www/site_root。