2012-03-24 60 views
0

我的客戶端有一個godaddy虛擬專用服務器(是的,我知道它很爛)....它有WHM VPS優化運行在它上面。Expression Engine刪除index.php使用.htaccess不工作

我想從網址中刪除index.php,但我的服務器仍然顯示404錯誤我已經看過宇宙中的每個論壇,並且無法獲取可用的htaccess文件。以下是表達式引擎告訴你投入使用......

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico) 
    RewriteRule ^(.*)$ /index.php/$1 [L] 
    </IfModule> 

我知道diddly關於Apache ..請幫助樣的先生們......

+0

是否mod_rewrite實際啓用? http://www.mostafaberg.com/2011/04/enabling-mod_rewrite-on-apache2/ – baynezy 2012-03-24 08:48:04

+0

使用什麼彼得張貼下面我不認爲這是...我試圖使用您的資源,並已登錄到根ssh但命令「sudo a2enmod rewrite」提示「a2enmod:command not found」...就像我說的,我對ssh和apache的瞭解很少,只是試圖在這裏獲得一些漂亮的seo友好的url。 – 2012-03-24 22:47:20

+0

和服務器正在運行阿帕奇2.2 – 2012-03-24 23:04:31

回答

0

測試如果htaccess的工作:

# Redirect domain 
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ 
RewriteRule ^/?$ "http\:\/\/google\.com" [R=301,L] 

或者

# Remove the www from the URL 
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

確保當你進入的index.php你確實有出現的內容:P

一旦你知道你的htaccess正在嘗試 「$ 1」,而不是 「%{REQUEST_URI}」:

RewriteEngine on 
RewriteCond $1 !^(img|admin\.php|themes|robots\.txt|index\.php|sitemap\.xml|/favicon\.ico) [NC] 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

也可以嘗試 「/index.php?/$1」 而不是「/index.php/ $ 1「

確保您已將EE(Admin-> General Configuration)設置爲」您網站的索引頁名稱「爲空。

請記住,一旦你確實讓EE工作,而沒有index.php出現,它可以使用兩種方式(有和沒有),這是不利於搜索引擎優化,所以刪除它像這樣(上述重寫之前: )

# Redirect index.php Requests (prevent site showing index.php in browser address bar) 
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] 
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L] 
+0

#重定向域 的RewriteCond%{HTTP_HOST}^www.yourdomain.com $ 重寫規則^/$ 「HTTP \:\/\ /谷歌\ .COM」?[R = 301,L] ___ 是不工作,所以顯然也沒有.htaccess ...呃... – 2012-03-24 22:42:41