Hi,
I'm having problems with a RewriteRule that's applied to url's with the %
character in them, hope someone can help. The % character is a result of
url-encoding non-ASCII words, as in the example below:
1. the word "sécurité" comes out of my db
2. I construct the following link, using the php urlencode function:
<a href="/search/s%C3%A9curit%C3%A9">sécurité</a>
3. the url created should be interpreted by a RewriteRule:
RewriteRule ^search/([a-zA-Z0-9-+%]+)$ /pages/search.php?word=$1 [QSA,L]
However the RewriteRule doesn't match on my url, and I see this in the
RewriteLog:
init rewrite engine with requested uri /search/sécurité
So it seems like some kind of decoding is going on so that the RewriteRule
never even sees the % character. I have set everything I can think of
(MySql SET NAMES, Apache AddDefaultCharset) to utf-8.
Any ideas?
TIA,
JON 7 4530
"Jon Maz" <pp****************@gmx.removethistoo.netschreef in bericht
news:eq**********@aioe.org...
I'm having problems with a RewriteRule that's applied to url's with the %
character in them, hope someone can help. The % character is a result of
url-encoding non-ASCII words, as in the example below:
1. the word "sécurité" comes out of my db
2. I construct the following link, using the php urlencode function:
<a href="/search/s%C3%A9curit%C3%A9">sécurité</a>
3. the url created should be interpreted by a RewriteRule:
RewriteRule ^search/([a-zA-Z0-9-+%]+)$ /pages/search.php?word=$1
[QSA,L]
However the RewriteRule doesn't match on my url, and I see this in the
RewriteLog:
init rewrite engine with requested uri /search/sécurité
So it seems like some kind of decoding is going on so that the RewriteRule
never even sees the % character. I have set everything I can think of
(MySql SET NAMES, Apache AddDefaultCharset) to utf-8.
So php has encoded the url to some ISO8859 variant and apache is decoding
those to some utf ... next to wonder is the charset used by your OS to
store the file name ...
In general, just forget diacritial, language specific, fancy characters and
just use 'securite' for filename.
It keeps you from dozens of cross-platform and cross-language traps, easing
migration of a website ten fold. http://czyborra.com/charsets/iso8859.html 'The ISO 8859 Alphabet Soup'
HansH
Hi Hans,
Thanks for your answer. I guess I'm best off just avoiding the whole thing.
What got me wondering was the fact that my php application can cope fine
when this encoded word is passed in the query string:
/pages/search.php?word=s%C3%A9curit%C3%A9
But perhaps it's simply that different rules apply to a url and a query
string parameter?
Thanks,
JON
"Jon Maz" <pp****************@gmx.removethistoo.netwrote in message
news:eq**********@aioe.org...
Hi,
I'm having problems with a RewriteRule that's applied to url's with the %
character in them, hope someone can help. The % character is a result of
url-encoding non-ASCII words, as in the example below:
1. the word "sécurité" comes out of my db
2. I construct the following link, using the php urlencode function:
<a href="/search/s%C3%A9curit%C3%A9">sécurité</a>
How do you get s%C3%A9curit%C3%A9 from sécurité
sécurité, url encoded, is s%E9curit%E9
s%C3%A9curit%C3%A9 decoded is sécurité as is correctly reported in your rewrite log.
>
3. the url created should be interpreted by a RewriteRule:
RewriteRule ^search/([a-zA-Z0-9-+%]+)$ /pages/search.php?word=$1 [QSA,L]
a hyphen in a character class specifies a range unless it's the first or last character in
the class
what range are you looking for with 9-+
>
However the RewriteRule doesn't match on my url, and I see this in the
RewriteLog:
init rewrite engine with requested uri /search/sécurité
The rewrite rule works correctly, the uri contains à and ©. The regex doesn't allow for
these.
>
So it seems like some kind of decoding is going on so that the RewriteRule
never even sees the % character. I have set everything I can think of
(MySql SET NAMES, Apache AddDefaultCharset) to utf-8.
The uri is decoded before the server tries to resolve it, why would it not?
Why are you trying to do the heavy lifting with mod rewrite? just pass the search term to
the script and validate it there, you should validate all user input in your scripts.
RewriteRule ^search/(.+)$ /pages/search.php?word=$1 [QSA,L]
Rich
On Sun, 4 Feb 2007 21:49:08 -0000
"Jon Maz" <pp****************@gmx.removethistoo.netwrote:
So it seems like some kind of decoding is going on so that the
RewriteRule never even sees the % character. I have set everything I
can think of (MySql SET NAMES, Apache AddDefaultCharset) to utf-8.
No you haven't. The expression in your RewriteRule is firmly in
ASCII, so it fails to match the non-ASCII characters in the URL.
Any ideas?
Don't faff about with mod_rewrite like that. Or if you
really must, fix your regexp. Or as someone else said,
stick to ASCII.
--
Nick Kew
Application Development with Apache - the Apache Modules Book http://www.apachetutor.org/
Thanks to everybody for their help on this one!
Thanks to everybody for their help on this one!
"rh" <di*************@cableone.netwrote:
> "Jon Maz" <pp****************@gmx.removethistoo.netwrote:
>> I'm having problems with a RewriteRule that's applied to url's with the % character in them, hope someone can help. The % character is a result of url-encoding non-ASCII words, as in the example below:
1. the word "sécurité" comes out of my db
2. I construct the following link, using the php urlencode function: <a href="/search/s%C3%A9curit%C3%A9">sécurité</a>
How do you get s%C3%A9curit%C3%A9 from sécurité
sécurité, url encoded, is s%E9curit%E9
Only in iso-8859-1. In UTF-8, the OP's encoding is correct.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JZ |
last post by:
I would like to exclude some files from Plone control within the same
virtual host. The problem is, I cannot use mod_rerwite because Plone needs
mod_proxy for working correctly. So the following...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: frizzle |
last post by:
Hi group,
I have the htaccess code that is below to redirect everything to
index.php exept for the mentioned folders. (img, swf, js and css)
Now when i try to access domain.com/testfolder/img...
|
by: frizzle |
last post by:
Hi there,
i have a site with fake folders & files.
htaccess rewrites everything to index.php?vars
now in index.php i decide what file to include with a switch/case
statement.
to define where...
|
by: Rik G. |
last post by:
I'm trying to replace a PHP query string with virtual directories using
Apache's mod_rewrite. Here's my test .htaccess:
RewriteEngine on
RewriteRule ^qqq$ database.php?cat=0
RewriteRule...
|
by: weetat.yeo |
last post by:
Hi all ,
I have a form that allow user to enter description , sometimes the
description value have html special character for example %20 and etc.
Inserting into the mysql database is ok , for...
|
by: David |
last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll
get an answer, so trying here.
I'm trying to convert a script to use friendly URLs, I've done this
before, but my PHP...
|
by: cssExp |
last post by:
hello i seem to be having some problem. Consider the following.
<Files index>
ForceType application/x-httpd-php
</Files>
RewriteEngine On
RewriteRule ^(+)/?$ index.php?ref=$1
RewriteRule...
|
by: WP |
last post by:
Hello, I'm trying to write a C# version of a simple Java program (that
uses swing for its gui). I'm using Visual C# 9.0 SP1 (2008) and I'm
using winforms for the gui.
Here's my problem. I want a...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |