2012-03-24 65 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