urlencode() function causes 403 error

Problems with the Windows version of XAMPP, questions, comments, and anything related.

urlencode() function causes 403 error

Postby jimbob2812 » 12. May 2011 11:53

Hi all,

I am using .htaccess to rewrite nice looking URL's to one output page called results.php and a query string:
RewriteRule category-(.+).html results.php?c=$1

This works as expected (eg. category-coffee.html correctly ends up on results.php and I can retrieve coffee from the query string c)
However, some of my categories contain accent characters.

I am trying to use urlencode() and urldecode() to retrieve the accents.
For example, thé.
This gives category-th%E9.html

On my hosting company, this operates correctly and I end up on my results.php retrieving thé from the query string c
On localhost, all I see is a Forbidden 403 page.

Can anyone explain why this is not working on localhost and yet works on a 'real' hosted server?
Also - how can I get it to work on localhost?

Thanks in advance,
jimbob2812
 
Posts: 4
Joined: 12. May 2011 11:41

Re: urlencode() function causes 403 error

Postby Sharley » 13. May 2011 01:04

Read the \xampp\apache\logs\error.log file for more details about your 403 error.

Remember that the paths on your hosted server will be different to the paths in XAMPP - you did put your files in a folder in the htdocs folder?
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: urlencode() function causes 403 error

Postby jimbob2812 » 13. May 2011 05:42

Thanks Sharley!

The line in the error log is:
Code: Select all
[Fri May 13 06:30:36 2011] [error] [client 127.0.0.1] (22)Invalid argument: Cannot map GET /site37/category-th%E9.html HTTP/1.1 to file

The line in the access log is:
Code: Select all
127.0.0.1 - - [13/May/2011:06:30:36 +0200] "GET /site37/category-th%E9.html HTTP/1.1" 403 1199 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24"

Whereas a category without accent characters like 'Cafe' shows no line in the error log and the following in the access log:
Code: Select all
127.0.0.1 - - [13/May/2011:06:37:10 +0200] "GET /site37/category-Cafe.html HTTP/1.1" 200 29611 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24"

Does this mean anything to you?

It is still the same thing though - the version of my site on the Internet hosted by a hosting company works...all categories with or without accents are correctly processed.
It is as if the urlencoded characters are not acceptable on my local configuration.
And I wish I knew why for development purposes.
jimbob2812
 
Posts: 4
Joined: 12. May 2011 11:41

Re: urlencode() function causes 403 error

Postby Sharley » 13. May 2011 05:59

Look at \xampp\apache\conf\extra\httpd-languages.conf file and see if setting the language order from the default en to say fr, which uses accented characters, helps.

Reading the comments in the above file may give some clues.

Remember to save the file and restart Apache after making any changes.

Best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: urlencode() function causes 403 error

Postby jimbob2812 » 13. May 2011 09:59

Thanks for the idea Sharley, but no joy.
I tried changing a few things in the \xampp\apache\conf\extra\httpd-languages.conf file and still same error :(
jimbob2812
 
Posts: 4
Joined: 12. May 2011 11:41

Re: urlencode() function causes 403 error

Postby jimbob2812 » 13. May 2011 11:35

Hi all,
Spent the morning searching French sites (the problem is to do with accented characters) and found others with the same problem.
Most avoided it by removing all references to accents.

There is one solution I would like to share.
Priot to the URLENCODE(), perform a UTF8_ENCODE()
My php code becomes: $category=urlencode(utf8_encode($category));
This is then used in the URL and all works on local and still on my hosting company's server.

I am not too sure why this works, but it has solved my problem.

Thanks for all views and help...
jimbob2812
 
Posts: 4
Joined: 12. May 2011 11:41

Re: urlencode() function causes 403 error

Postby Sharley » 13. May 2011 12:09

Thanks for posting back with your solution, which may help others with a similar issue searching these forums for a solution.

Often I wish more members would do the same.

Good luck and best wishes. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 61 guests