Forum Moderators: phranque

Message Too Old, No Replies

.htaccess syntax question

Is there an apache token for spaces?

         

FireStorm

8:46 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



I have a redirect setup that needs to redirect to a location that is a query such as:

[example.com...] name&entry=store

The problem is that the customer created a username that has a space such as "user name". It displays fine when entering the query directly because the browser automatically enters a %20 for the space. However, when redirecting through Apache, the space is not interpreted and cuts it off as:

[example.com...]

I tried entering the %20 as part of the redirection query but the system doesn't understand the %20 properly since the actual username contains a space.

Is there an Apache token that can be entered where the space is so that Apache can process the redirect correctly?

jdMorgan

9:45 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Firestorm,

Welcome to WebmasterWorld!

I presume you're using mod_rewrite to do this, so you're looking for a regular-expressions token, not an Apache token. In mod_rewrite, you can usually use either "\ " or "\s" depending on the version on regex installed with the server OS.

If that doesn't work, the general solution for handling percent-escaped characters is presented in post #10 of this thread: [webmasterworld.com...]

Jim

FireStorm

9:56 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



Hi Jim,

So I would edit the .htaccess file with:

[example.com...] name&entry=store

or

[example.com...] name&entry=store

For Apache to recognize and process the space properly?

jdMorgan

10:10 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, in theory. In practice it may be a bit more involved than that...

Since we haven't seen your existing code related to this problem, it's a bit hard to tell.

Jim

FireStorm

10:15 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



Ok, I'll give it a try in a few minutes and see what happens...

Thanks for the info. :-)

FireStorm

10:27 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



Jim,

Whoo hoo! The "\ " worked like a charm. Thank you so much for the insight.