本文介绍了重写规则htaccess的隐藏的默认语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在Zend的默认配置我有这些规则: SETENV APPLICATION_ENV离线RewriteEngine叙述在选择了FollowSymLinks +的RewriteCond%{} REQUEST_FILENAME -s [OR]的RewriteCond%{} REQUEST_FILENAME -l [OR]的RewriteCond%{} REQUEST_FILENAME -d。重写规则^ * $ - [NC,L]重写规则^ * $的index.php [NC,L] 当我尝试添加休耕线,notfing情况: 重写规则^ EN /(.*)$ 1 [L] 在结果我expact改写permomently http://example.com/en/something 以 http://example.com/something 在我现在有两个链接separatly工作。编辑: SETENV APPLICATION_ENV离线RewriteEngine叙述在选择了FollowSymLinks +的RewriteCond%{} REQUEST_FILENAME -s [OR]的RewriteCond%{} REQUEST_FILENAME -l [OR]的RewriteCond%{} REQUEST_FILENAME -d。重写规则^ * $ - [NC,L]的RewriteCond%{REQUEST_URI}!^ / EN /重写规则^ * $的index.php [NC,L]重写规则^恩/(.*)/ $ 1 [L,R] 这将直接重定向默认语言的URL站点根目录!非常感谢。有是lighttpd的: $ HTTP [网址]!=^ / EN /{    url.rewrite一次=(        ^ / *=> 的index.php?/ $ 1,    )}url.redirect =(    ^ / EN /.*=> / $ 1,) 解决方案 这是bceause 重写规则^ * $的index.php [NC,L] 正在改写它,它永远不会给你添加的规则。您需要添加一个条件,使请求开始 / EN / 没有得到改写为index.php文件: #你经常东西RewriteEngine叙述在选择了FollowSymLinks +的RewriteCond%{} REQUEST_FILENAME -s [OR]的RewriteCond%{} REQUEST_FILENAME -l [OR]的RewriteCond%{} REQUEST_FILENAME -d。重写规则^ * $ - [NC,L]#添加此条件的RewriteCond%{REQUEST_URI}!^ / EN /重写规则^ * $的index.php [NC,L]#现在你可以重写/ EN重写规则^恩/(.*)$ 1 [L,R] 编辑: example.com/en/something 被重定向到 example.com/something ,然后改写为的index.php 。In Zend configuration defaults I have these rules:SetEnv APPLICATION_ENV offlineRewriteEngine OnOptions +FollowSymlinksRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^.*$ - [NC,L]RewriteRule ^.*$ index.php [NC,L]When i try to add fallowing line, notfing happens:RewriteRule ^en/(.*) $1 [L]On result I expact to rewrite permomently http://example.com/en/something to http://example.com/somethingAt now I have both links worked separatly.Edited:SetEnv APPLICATION_ENV offlineRewriteEngine OnOptions +FollowSymlinksRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^.*$ - [NC,L]RewriteCond %{REQUEST_URI} !^/en/RewriteRule ^.*$ index.php [NC,L]RewriteRule ^en/(.*) /$1 [L,R]This will redirects default language urls directly to site root!Many thanks.There is for LigHTTPD:$HTTP["url"] != "^/en/" { url.rewrite-once = ( "^/.*" => "index.php?/$1", )}url.redirect = ( "^/en/.*" => "/$1",) 解决方案 It's bceause RewriteRule ^.*$ index.php [NC,L] is rewriting it and it never gets to the rule you added. You need to add a condition so that requests starting with /en/ don't get rewritten to index.php:# you regular stuffRewriteEngine OnOptions +FollowSymlinksRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^.*$ - [NC,L]# Add this conditionRewriteCond %{REQUEST_URI} !^/en/RewriteRule ^.*$ index.php [NC,L]# Now you can rewrite /enRewriteRule ^en/(.*) $1 [L,R]Edited: example.com/en/something gets redirected to example.com/something, then rewritten to index.php. 这篇关于重写规则htaccess的隐藏的默认语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-16 00:11