如何在 .htaccess 文件中使用空格和非 ascii 字符
在 .htaccess imposibla 中使用空格、非拉丁字符等? 例如,如何解决这个问题:
RewriteRule ^/(.*)/new user/(.*)$ /page/?id=$1 [QSA,L,E]
这个决定不是我做的:
... /new_user/ ...
谢谢
in .htaccess imposibla use space, non-Latin characters and etc. ?
For example how, fix this:
RewriteRule ^/(.*)/new user/(.*)$ /page/?id=$1 [QSA,L,E]
this decision is not me:
... /new_user/ ...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须使用百分号编码中各自的字符代码对 URI 的保留字符进行转义,例如
%20
表示空格。有关更多信息,请参阅 http://en.wikipedia.org/wiki/Percent-encoding细节。
You have to escape the reserved characters for URIs with their respective character codes in percent-encoding, e. g.
%20
for a space.See http://en.wikipedia.org/wiki/Percent-encoding for more details.
好的..网址中允许使用符号:
http://www.blooberry.com/indexdot/html/topics/urlencoding。嗯
并在 htaccess 中:
更改
www.blabla.com/10-new_user-5
到
www.blabla.com/new_user.php?page=10&id=5
OK .. signs allowed in url:
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
and in htaccess:
change
www.blabla.com/10-new_user-5
to
www.blabla.com/new_user.php?page=10&id=5
URL 在您的规则对其进行操作之前会自动解码,因此您可以针对文字字符进行测试,例如
français\ español
(请注意,您需要使用反斜杠转义文字空格,除非模式被引用) 。然而,根据你的例子,我认为你真正关心的是能够做这样的事情:
The URL is automatically decoded before your rules operate on it, so you can test against literal characters, e.g.
français\ español
(note that you need to escape literal spaces with a backslash, unless the pattern is quoted).However, based on your example, I think your actual concern is being able to do something like this: