[英]php htaccess url encode/decode remove trailing slash
I'm using .htaccess
to remove trailing slash from URI: 我正在使用.htaccess
从URI中删除结尾的斜杠:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ $1 [R=301,L]
The website is built with Codeigniter
and has three languages, where russian is one of them, that uses cyrillic chars in URI.I use urlencode
for generating routes and urldecode
to find the right page from database by URI. 这个网站是用Codeigniter
构建的,有三种语言,其中俄语是其中一种,它在URI中使用西里尔字符。我使用urlencode
生成路由,并使用urldecode
通过URI从数据库中找到正确的页面。
Removing trailing slash works fine with english and german languages, but when I try add trailing slash to URI where cyrillic chars are used, I get 404 page. 删除尾部斜杠在英语和德语中都可以正常工作,但是当我尝试在使用西里尔字符的URI中添加尾部斜杠时,得到404页。 URI after removing /
seems correct, but I can't understand why I get 404, the URL is the same as entered without trailing slash. 删除/
后的URI似乎是正确的,但我不明白为什么会得到404,该URL与输入的相同,没有尾部斜杠。
Use NE
flag for not encoding: 使用NE
标志进行不编码:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/$ $1 [R=301,L,NE]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.