在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 example/en/something 以 example/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/en/something 被重定向到 example/something ,然后改写为的index.php 。
In Zend configuration defaults I have these rules:
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]When i try to add fallowing line, notfing happens:
RewriteRule ^en/(.*) $1 [L]On result I expact to rewrite permomently example/en/something to example/something At now I have both links worked separatly.
Edited:
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]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 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]Edited: example/en/something gets redirected to example/something, then rewritten to index.php.
更多推荐
重写规则htaccess的隐藏的默认语言
发布评论