重写规则htaccess的隐藏的默认语言

编程入门 行业动态 更新时间:2024-10-25 12:16:37
本文介绍了重写规则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 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的隐藏的默认语言

本文发布于:2023-11-01 02:30:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547999.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   规则   语言   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!