.htaccess的语言重定向310错误(Htaccess language Redirect 310 error)

   IT问题网   2018-12-07 00:00:00

问 题

我有两个语言的网站

 瑞典方面www.site.com
英方www.site.com/lang=en
 

我用

rewriteengine叙述上
的rewritecond%{http:接受语言} (aa|ab|af|am|ar|as|ay|az|ba|be|bg|bh|bi|bn|bo|br|ca|co|cs|cy|da|de|dz|el|en|eo|es|et|eu|fa|fi|fj|fo|fr|fy|ga|gd|gl|gn|gu|ha|hi|hr|hu|hy|ia|ie|ik|in|is|it|iw|ja|ji|jw|ka|kk|kl|km|kn|ko|ks|ku|ky|la|ln|lo|lt|lv|mg|mi|mk|ml|mn|mo|mr|ms|mt|my|na|ne|nl|no|oc|om|or|pa|pl|ps|pt|qu|rm|rn|ro|ru|rw|sa|sd|sg|sh|si|sk|sl|sm|sn|so|sq|sr|ss|st|su|sw|ta|te|tg|th|ti|tk|tl|tn|to|tr|ts|tt|tw|uk|ur|uz|vi|vo|wo|xh|yo|zh|zu) [nc]
重写规则。* www.site.com/lang=en [l]
 

要获得所有语言,但瑞典的 www.site.com/lang=en ,但我最终在一个310环。 缺什么?

解决方案

您需要添加一个检查郎,以确保你不循环。

rewriteengine叙述上
的rewritecond%{query_string}(安培; | ^)!lang =
的rewritecond%{http:接受语言} (aa|ab|af|am|ar|as|ay|az|ba|be|bg|bh|bi|bn|bo|br|ca|co|cs|cy|da|de|dz|el|en|eo|es|et|eu|fa|fi|fj|fo|fr|fy|ga|gd|gl|gn|gu|ha|hi|hr|hu|hy|ia|ie|ik|in|is|it|iw|ja|ji|jw|ka|kk|kl|km|kn|ko|ks|ku|ky|la|ln|lo|lt|lv|mg|mi|mk|ml|mn|mo|mr|ms|mt|my|na|ne|nl|no|oc|om|or|pa|pl|ps|pt|qu|rm|rn|ro|ru|rw|sa|sd|sg|sh|si|sk|sl|sm|sn|so|sq|sr|ss|st|su|sw|ta|te|tg|th|ti|tk|tl|tn|to|tr|ts|tt|tw|uk|ur|uz|vi|vo|wo|xh|yo|zh|zu) [nc]
重写规则。* http://www.site.com/lang=%1 [l]
 

注意%1 是一个反向引用,在previous匹配的rewritecond的2字母语言code。有关规则要注意的另一件事是,像 /something/file.html 的请求会被重定向到 http://www.site。 com /?lang =(2字母语言code)。本质上,原来的路径丢失。如果你想保留它,你需要匹配,并使用一个反向引用:

 重写规则^(。*)$ http://www.site.com/$1lang=%1 [l]
 

如果你想previous查询字符串也获得通过,例如, /something/file.phpa=b ,你需要添加 qsa 在括号中,这样它会被重定向到 http://www.site.com/somthing/file.phplang=(2字母语言$ c $三)及; a = b

标签:语言定向错误过错毛病谬误



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

重定向一切的index.php(Redirection everything to index.php)

problem i wan't to redirect everything to index.php exepe ...

生成SE友好的URL的.htaccess国防部重写(Generating SE friendly URL .htaccess mod rewrite)

problem i've a url which get file name through get method ...

htaccess的子域名重定向(htaccess subdomain redirect)

problem i've searched around and tried a few ...

UrlRewrite 3 GET请求(UrlRewrite with 3 get request)

problem i'm working on a project and stuck on urlrewrite. ...

mod_rewrite的:恶意重定向(Mod_ReWrite: Unwanted redirect)

problem possible duplicate: .htaccess, clean ...

限制用户子目录(limiting users to subdirectories)

problem i have a subdirectory of users that i want to lim ...

重定向子文件夹的.htaccess(Redirection Subfolder Htaccess)

problem i want a redirect using htaccess i have a post na ...

使用的.htaccess,从来没有表现出的index.php(Using .htaccess, never show index.php)

problem how can i never show index.phpfor example, all re ...

在子域的内部服务器错误(internal server error in subdomains)

problem i installed worpress to my main domain abcd.com. ...

基于用户代理手机网站重定向(Mobile website redirection based on user agent)

problem say i've got two distinct domains: ...

的Joomla htaccess的不工作(Joomla htaccess not working)

problem i am using joomla 1.7 and using joomla's built in ...

扩大友好的URL,国防部重写(Expanding friendly url, mod rewrite)

problem i am using modx, which is a cms system. it has a ...

共享主机Zend的项目?(zend project on shared hosting )

problem i created a zend project on localhost on ubuntu o ...

URL结构的htaccess(url construction htaccess)

problem lets say i have a link to one of my page that loo ...

htaccess的重写规则(.htaccess RewriteRule)

problem i'm trying to write a rewriterule (with no luck) ...

如何配置.htaccess文件的重写规则摆脱扩展,尾随斜线,WWW?(How to configure .htaccess file for rewrite rules to get rid of extensions, trailing slashes, www)

problem this is what i want - when somebody enters site. ...

htaccess的基础上与通配符和东西后,到index.php index.php页面重定向不存在的页面(.htaccess redirect non existing pages based on index.php page with wildcard and something after it to index.php)

problem please help, some website is arbitrar ...

国防部重写的子域子域目录(mod-rewrite subdomain to subdomain dir)

problem i have a bit of a problem with rewrite rules; so ...

如何使用的.htaccess忽略/删除/页/ X /从网址是什么?(How to use .htaccess to ignore/remove /page/X/ from url)

problem how can i use .htaccess to strip/ignore /page/x/ ...

变化的RewriteBase视域(change RewriteBase depending on domain)

problem i have to set rewritebase depending o ...