user319854
user319854

Reputation: 4126

How do I use space and non-ascii characters in .htaccess files

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

Upvotes: 0

Views: 962

Answers (3)

Tim Stone
Tim Stone

Reputation: 19189

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:

RewriteRule ^([^/]+)/[^/]+/.*$ /page/?id=$1 [QSA,L]
#                    ^---^
#                       it doesn't matter what the user name is, as long as it
#                       doesn't contain a slash

Upvotes: 0

joschi
joschi

Reputation: 13101

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.

Upvotes: 1

jatt
jatt

Reputation: 398

OK .. signs allowed in url: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm and in htaccess:

RewriteRule ^(([0-9]+)-)?new_user(-([0-9]+))?/?$   new_user.php?page=$2&id=$4 [L] 

change www.blabla.com/10-new_user-5
to www.blabla.com/new_user.php?page=10&id=5

Upvotes: 0

Related Questions