RewriteRule为htaccess隐藏默认语言

在Zendconfiguration默认情况下,我有这些规则:

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] 

在结果我扩大重写http://example.com/en/something到http://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] 

这将直接将默认语言urlredirect到网站根目录! 非常感谢。

有LigHTTPD:

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

这是因为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