I'm using jQuery Mobile and its mostly good. Although there are a few errors.
For example; I put in my HTML &
instead of &
like you're meant to. jQuery doesn't read it properly and when it shows it in the url has &
showing instead of &
like its meant to.
For example
<a href="index.php?foo=true&bar=false">Hello</a>
It will go to
example.com/index.php?foo=true&bar=false
when really it should go to
example.com/index.php?foo=true&bar=false
It's really annoying and I use lots of them so I cannot manally write a .htaccess because all the get variables change and it would be a very long file it I did write every possible foo and bar.
My question is: Is the开发者_开发知识库re a quick way for an apache server to correct &
to &
?
The string index.php?foo=true&bar=false
, when used as an attribute's value, is decoded as index.php?foo=true&bar=false
by the browser.
So, clicking on this link:
<a href="index.php?foo=true&bar=false">Hello</a>
Goes to index.php?foo=true&bar=false
, not index.php?foo=true&bar=false
.
This is because &
is a special character in HTML, and &
is how you can encoded it to remove its special meaning.
It's actually invalid to write <a href="index.php?foo=true&bar=false">
, and perfectly valid to write <a href="index.php?foo=true&bar=false">
.
If jQuery reads it wrongly, there must be a bug in jQuery, or you are doing something wrong.
If you have tons users of using doing requests to index.php?foo=true&bar=false
, you may want to rewrite the request like this:
RewriteCond %{THE_REQUEST} ^(GET|HEAD) (.*)&(.*) HTTP/[\d.]+$
RewriteRule %2&%3 [R]
(Using RewriteCond and matching on %{THE_REQUEST} because a RewriteRule won't match on the query string.)
This will redirect the user to the URL with &
decoded to &
. If there is multiple &
, there will be multiple redirects.
精彩评论