重写URL以在其中包含空格的额外参数 [英] Rewrite a URL to include an extra parameter with a space in it
本文介绍了重写URL以在其中包含空格的额外参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在 .htaccess会被重写所有网址并包含一个参数,该参数如何在其中留有空格?
Now that .htaccess rewrites all URLs and includes a parameter, how can that parameter have a space in it?
例如
- http://old.io --> http://new.com?pa=v%20a
%20
在在.htaccess模拟器中进行测试时可以工作,但在我的计算机上不起作用DreamHost帐户.
While %20
works when testing in a .htaccess simulator, it doesn't work on my DreamHost account.
- http://new.com?pa=v%20a -> http://new.com?pa=v0a
- http://new.com?pa=v \ a-> http://new.com?pa=va
- http://new.com?pa=v%2520a -> http://new.com?pa=v520a
- 添加 NE 标志没有任何改变
- http://new.com?pa=v%20a --> http://new.com?pa=v0a
- http://new.com?pa=v\ a --> http://new.com?pa=v a
- http://new.com?pa=v%2520a --> http://new.com?pa=v520a
- adding the NE flag doesn't change anything
推荐答案
您是对的;即使添加%20
在模拟器中也可以使用,但在实际的httpd服务器上则不起作用.
You're right; Even though adding %20
works in the simulator, it does not work on a real httpd server.
要添加空格,您需要使用\
对其进行转义.这是您的htaccess文件的样子:
To add a space, you need to escape it with a \
. Here's what your htaccess file looks like:
RewriteEngine on
RewriteBase /
# Check if the host matches old.io,
# You might want to add www\. to that.
RewriteCond %{HTTP_HOST} ^old\.io
# Rewrite URLs with empty querystring
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ http://new.com/$1?pa=v\ a [L,R]
# Rewrite URLs with non-empty querystring
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^(.*)$ http://new.com/$1?pa=v\ a&%{QUERY_STRING} [L,R]
注意RewriteRule
指令中的pa=v\ a
.
这篇关于重写URL以在其中包含空格的额外参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文