Spaces in Map Files
5 posts
• Page 1 of 1
- webthinking
-
- Posts: 2
- Joined: 21 Aug 2013, 21:24
Spaces in Map Files
Hi,
How do I handle spaces in key names in a map file? For example, I wish to do a look-up on the following:
I'm using this code in htaccess:
Currently, anything I pass in with a space is not matched. What should I do to resolve this?
Thanks
Mark
How do I handle spaces in key names in a map file? For example, I wish to do a look-up on the following:
- Code: Select all
mykeyname 123
my key name 456
I'm using this code in htaccess:
- Code: Select all
RewriteMap mapfile txt:MAP.htaccess [NC]
RewriteCond %{HTTP:Host} ^(.+)$
RewriteCond ${mapfile:%1$1} ^(.+)$
RewriteRule ^(/.*)$ /mypage.aspx\?id=${mapfile:%1$1} [NC,L,QSA]
Currently, anything I pass in with a space is not matched. What should I do to resolve this?
Thanks
Mark
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Spaces in Map Files
Unfortunately, a space is a special character in mapfiles. And usually spaces are considered non-secure characters from IIS point of view.
We'd suggest dealing with spaces in separate rule and use mapfiles only for URLs without spaces.
Regards
Andrew
We'd suggest dealing with spaces in separate rule and use mapfiles only for URLs without spaces.
Regards
Andrew
Re: Spaces in Map Files
HeliconAndrew wrote:Unfortunately, a space is a special character in mapfiles. And usually spaces are considered non-secure characters from IIS point of view.
We'd suggest dealing with spaces in separate rule and use mapfiles only for URLs without spaces.
Regards
Andrew
Or, better- don't put spaces in URLs! It's nasty.
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Spaces in Map Files
I recently played around and it turned out you can try to use "%20" or escape the spaces "\ ".
- webthinking
-
- Posts: 2
- Joined: 21 Aug 2013, 21:24
Re: Spaces in Map Files
Hi, sorry for the delay in responding - I had reply notifications turned off by mistake. I've now got this working by storing key names with %20 and then looking up using the following:
I completely agree about spaces in URLs being nasty. However, this is for a CMS, so I would like to have spaces handled correctly in this part of the system, then deal with rules regarding their use elsewhere. Thanks for the help.![Smile :)](./images/smilies/icon_e_smile.gif)
- Code: Select all
RewriteMap mapfile txt:MAP.htaccess [NC]
RewriteMap mapfile2 int:escape
RewriteCond %{HTTP:Host} ^(.+)$
RewriteCond ${mapfile:${mapfile2:%1$1}} ^(.+)$
RewriteRule ^(/.*)$ /mypage.aspx\?id=${mapfile:${mapfile:%1$1}} [NC,L,QSA]
I completely agree about spaces in URLs being nasty. However, this is for a CMS, so I would like to have spaces handled correctly in this part of the system, then deal with rules regarding their use elsewhere. Thanks for the help.
![Smile :)](./images/smilies/icon_e_smile.gif)
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests