2011-11-15 31 views
0

在Zend的默认配置我有这些规则:重写规则的htaccess的隐藏的默认语言

SetEnv APPLICATION_ENV offline 

RewriteEngine On 
Options +FollowSymlinks 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

当我尝试添加休耕线,notfing情况:

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

在结果我expact改写permomently http://example.com/en/somethinghttp://example.com/something 现在我有两个链接分开工作。

编辑:

SetEnv APPLICATION_ENV offline 

RewriteEngine On 
Options +FollowSymlinks 

RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 

RewriteCond %{REQUEST_URI} !^/en/ 
RewriteRule ^.*$ index.php [NC,L] 

RewriteRule ^en/(.*) /$1 [L,R] 

这将直接重定向默认语言的网址网站的根! 非常感谢。

没有为lighttpd的:

$HTTP["url"] != "^/en/" { 
    url.rewrite-once = (
     "^/.*" => "index.php?/$1", 
    ) 
} 
url.redirect = (
    "^/en/.*" => "/$1", 
) 

回答

1

这是bceause RewriteRule ^.*$ index.php [NC,L]正在改写它,它永远不会给你添加的规则。您需要添加一个条件,以便开始/en/请求都不会改写为的index.php:

# you regular stuff 
RewriteEngine On 
Options +FollowSymlinks 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 

# Add this condition 
RewriteCond %{REQUEST_URI} !^/en/ 
RewriteRule ^.*$ index.php [NC,L] 

# Now you can rewrite /en 
RewriteRule ^en/(.*) $1 [L,R] 

编辑:example.com/en/something被重定向到example.com/something,然后重写index.php

+0

这似乎是有效的,但它不工作在我的网页。我如何检查所有重定向(php/http)? – iegik

+0

头: HTTP请求的状态:200(OK) 名称\t价值 日期\t星期二,2011年11月15 9点零零分19秒GMT X供电,通过\t PHP/5.2.11 连接\t保持活动 内容 - 长附注\t无缓存 服务器\t的Apache/2.2.21(的Win32)PHP/5.2.11 Content-Type的\t text/html的 缓存控制\t无店铺,无缓存,必重新验证,后检查= 0,预检查= 0 保持活跃\t超时= 5 ,max = 99 Expires \t Thu,19 Nov 1981 08:52:00 GMT – iegik

+0

如果您想要重定向,请在最后一条规则中将括号改为'[L,R]',但请注意,一旦浏览器被重定向,'RewriteRule ^。* $ index.php [NC,L]'规则将被应用。所以example.com/en/something被重定向到example.com/something,然后被重写为index.php。 –