Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I'm trying to access an url like image%20xyz.jpg, I got a 404 error.

When I look into the logs, Apache converts the %20 into \xa9 (and every url encoded characters are transformed to their \xXY values instead of the correct chars (space in that case).

I tried AllowEncodedSlashes but this doesn't work.

Which Apache directive should I put in my VirtualHost or .htaccess to make something like

/img/cms/MISC/Certifi%C3%A9%20AB.jpg

Become :

/img/cms/MISC/Certifié AB.jpg

And not :

/img/cms/MISC/Certifi\xc3\xa9 AB.jpg

Here's my Apache configuration :

<VirtualHost *:80>
        ServerName mywebsite.com
        Redirect / http://www.mywebsite.com/
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot "/home/mywebsite.com/www/"
        ServerName www.mywebsite.com

        <Directory "/home/mywebsite.com/www/">
                Options Includes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/mywebsite.com.error.log
        LogLevel warn
        CustomLog /var/log/apache2/mywebsite.com.access.log combined
        ServerSignature Off
</VirtualHost>

And my .htaccess (generated from Prestashop):

# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# WARNING: PLEASE DO NOT MODIFY THIS FILE MANUALLY. IF NECESSARY, ADD YOUR SPECIFIC CONFIGURATION WITH THE HTACCESS GENERATOR IN BACK OFFICE
# http://www.prestashop.com - http://www.prestashop.com/forums

SetEnv PHP_VER 5
<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine on

# URL rewriting rules
RewriteRule ^api/?(.*)$ /webservice/dispatcher.php?url=$1 [QSA,L]
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2$3.jpg [L]
RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2.jpg [L]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg [L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /category.php?id_category=$1 [QSA,L]
RewriteRule ^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*) /supplier.php?id_supplier=$1 [QSA,L]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*) /manufacturer.php?id_manufacturer=$1 [QSA,L]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms=$1 [QSA,L]
RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms_category=$1 [QSA,L]
RewriteRule ^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$2&isolang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$2&isolang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]* /category.php?id_category=$2&isolang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/content/([0-9]+)\-[a-zA-Z0-9-]* /cms.php?isolang=$1&id_cms=$2 [QSA,L]
RewriteRule ^([a-z]{2})/content/category/([0-9]+)\-[a-zA-Z0-9-]* /cms.php?isolang=$1&id_cms_category=$2 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)__[a-zA-Z0-9-]* /supplier.php?isolang=$1&id_supplier=$2 [QSA,L]
RewriteRule ^([a-z]{2})/([0-9]+)_[a-zA-Z0-9-]* /manufacturer.php?isolang=$1&id_manufacturer=$2 [QSA,L]
RewriteRule ^en/page-not-found$ /404.php?isolang=en [QSA,L]
RewriteRule ^en/address$ /address.php?isolang=en [QSA,L]
RewriteRule ^en/addresses$ /addresses.php?isolang=en [QSA,L]
RewriteRule ^en/authentication$ /authentication.php?isolang=en [QSA,L]
RewriteRule ^en/best-sales$ /best-sales.php?isolang=en [QSA,L]
RewriteRule ^en/cart$ /cart.php?isolang=en [QSA,L]
RewriteRule ^en/contact-us$ /contact-form.php?isolang=en [QSA,L]
RewriteRule ^en/discount$ /discount.php?isolang=en [QSA,L]
RewriteRule ^en/guest-tracking$ /guest-tracking.php?isolang=en [QSA,L]
RewriteRule ^en/order-history$ /history.php?isolang=en [QSA,L]
RewriteRule ^en/identity$ /identity.php?isolang=en [QSA,L]
RewriteRule ^en/manufacturers$ /manufacturer.php?isolang=en [QSA,L]
RewriteRule ^en/my-account$ /my-account.php?isolang=en [QSA,L]
RewriteRule ^en/new-products$ /new-products.php?isolang=en [QSA,L]
RewriteRule ^en/order$ /order.php?isolang=en [QSA,L]
RewriteRule ^en/order-follow$ /order-follow.php?isolang=en [QSA,L]
RewriteRule ^en/quick-order$ /order-opc.php?isolang=en [QSA,L]
RewriteRule ^en/order-slip$ /order-slip.php?isolang=en [QSA,L]
RewriteRule ^en/password-recovery$ /password.php?isolang=en [QSA,L]
RewriteRule ^en/prices-drop$ /prices-drop.php?isolang=en [QSA,L]
RewriteRule ^en/search$ /search.php?isolang=en [QSA,L]
RewriteRule ^en/sitemap$ /sitemap.php?isolang=en [QSA,L]
RewriteRule ^en/stores$ /stores.php?isolang=en [QSA,L]
RewriteRule ^en/supplier$ /supplier.php?isolang=en [QSA,L]
RewriteRule ^en/([^?&]*) /$1?isolang=en [QSA,L]
RewriteRule ^fr/page-non-trouvee$ /404.php?isolang=fr [QSA,L]
RewriteRule ^fr/adresse$ /address.php?isolang=fr [QSA,L]
RewriteRule ^fr/adresses$ /addresses.php?isolang=fr [QSA,L]
RewriteRule ^fr/authentification$ /authentication.php?isolang=fr [QSA,L]
RewriteRule ^fr/meilleures-ventes$ /best-sales.php?isolang=fr [QSA,L]
RewriteRule ^fr/panier$ /cart.php?isolang=fr [QSA,L]
RewriteRule ^fr/contactez-nous$ /contact-form.php?isolang=fr [QSA,L]
RewriteRule ^fr/bons-de-reduction$ /discount.php?isolang=fr [QSA,L]
RewriteRule ^fr/suivi-commande-invite$ /guest-tracking.php?isolang=fr [QSA,L]
RewriteRule ^fr/historique-des-commandes$ /history.php?isolang=fr [QSA,L]
RewriteRule ^fr/identite$ /identity.php?isolang=fr [QSA,L]
RewriteRule ^fr/fabricants$ /manufacturer.php?isolang=fr [QSA,L]
RewriteRule ^fr/mon-compte$ /my-account.php?isolang=fr [QSA,L]
RewriteRule ^fr/nouveaux-produits$ /new-products.php?isolang=fr [QSA,L]
RewriteRule ^fr/commande$ /order.php?isolang=fr [QSA,L]
RewriteRule ^fr/details-de-la-commande$ /order-follow.php?isolang=fr [QSA,L]
RewriteRule ^fr/commande-rapide$ /order-opc.php?isolang=fr [QSA,L]
RewriteRule ^fr/avoirs$ /order-slip.php?isolang=fr [QSA,L]
RewriteRule ^fr/mot-de-passe-oublie$ /password.php?isolang=fr [QSA,L]
RewriteRule ^fr/promotions$ /prices-drop.php?isolang=fr [QSA,L]
RewriteRule ^fr/recherche$ /search.php?isolang=fr [QSA,L]
RewriteRule ^fr/plan-du-site$ /sitemap.php?isolang=fr [QSA,L]
RewriteRule ^fr/magasins$ /stores.php?isolang=fr [QSA,L]
RewriteRule ^fr/fournisseurs$ /supplier.php?isolang=fr [QSA,L]
RewriteRule ^fr/([^?&]*) /$1?isolang=fr [QSA,L]
RewriteRule ^es/pagina-no-encuentra$ /404.php?isolang=es [QSA,L]
RewriteRule ^es/direccion$ /address.php?isolang=es [QSA,L]
RewriteRule ^es/direcciones$ /addresses.php?isolang=es [QSA,L]
RewriteRule ^es/autenticacion$ /authentication.php?isolang=es [QSA,L]
RewriteRule ^es/mas-vendidos$ /best-sales.php?isolang=es [QSA,L]
RewriteRule ^es/carro-de-la-compra$ /cart.php?isolang=es [QSA,L]
RewriteRule ^es/contactenos$ /contact-form.php?isolang=es [QSA,L]
RewriteRule ^es/descuento$ /discount.php?isolang=es [QSA,L]
RewriteRule ^es/estado-pedido$ /guest-tracking.php?isolang=es [QSA,L]
RewriteRule ^es/historial-de-pedidos$ /history.php?isolang=es [QSA,L]
RewriteRule ^es/identidad$ /identity.php?isolang=es [QSA,L]
RewriteRule ^es/fabricantes$ /manufacturer.php?isolang=es [QSA,L]
RewriteRule ^es/mi-cuenta$ /my-account.php?isolang=es [QSA,L]
RewriteRule ^es/nuevos-productos$ /new-products.php?isolang=es [QSA,L]
RewriteRule ^es/carrito$ /order.php?isolang=es [QSA,L]
RewriteRule ^es/devolucion-de-productos$ /order-follow.php?isolang=es [QSA,L]
RewriteRule ^es/pedido-rapido$ /order-opc.php?isolang=es [QSA,L]
RewriteRule ^es/vales$ /order-slip.php?isolang=es [QSA,L]
RewriteRule ^es/contrasena-olvidado$ /password.php?isolang=es [QSA,L]
RewriteRule ^es/promocion$ /prices-drop.php?isolang=es [QSA,L]
RewriteRule ^es/buscar$ /search.php?isolang=es [QSA,L]
RewriteRule ^es/mapa-del-sitio$ /sitemap.php?isolang=es [QSA,L]
RewriteRule ^es/tiendas$ /stores.php?isolang=es [QSA,L]
RewriteRule ^es/proveedores$ /supplier.php?isolang=es [QSA,L]
RewriteRule ^es/([^?&]*) /$1?isolang=es [QSA,L]
RewriteRule ^de/seite-nicht-gefunden$ /404.php?isolang=de [QSA,L]
RewriteRule ^de/adresse$ /address.php?isolang=de [QSA,L]
RewriteRule ^de/adressen$ /addresses.php?isolang=de [QSA,L]
R    ewriteRule ^de/authentifizierung$ /authentication.php?isolang=de [QSA,L]
RewriteRule ^de/verkaufshits$ /best-sales.php?isolang=de [QSA,L]
RewriteRule ^de/warenkorb$ /cart.php?isolang=de [QSA,L]
RewriteRule ^de/kontaktieren-sie-uns$ /contact-form.php?isolang=de [QSA,L]
RewriteRule ^de/discount$ /discount.php?isolang=de [QSA,L]
RewriteRule ^de/auftragsverfolgung-gast$ /guest-tracking.php?isolang=de [QSA,L]
RewriteRule ^de/bestellungsverlauf$ /history.php?isolang=de [QSA,L]
RewriteRule ^de/kennung$ /identity.php?isolang=de [QSA,L]
RewriteRule ^de/hersteller$ /manufacturer.php?isolang=de [QSA,L]
RewriteRule ^de/mein-Konto$ /my-account.php?isolang=de [QSA,L]
RewriteRule ^de/neue-Produkte$ /new-products.php?isolang=de [QSA,L]
RewriteRule ^de/bestellung$ /order.php?isolang=de [QSA,L]
RewriteRule ^de/bestellungsverfolgung$ /order-follow.php?isolang=de [QSA,L]
RewriteRule ^de/schnell-bestellung$ /order-opc.php?isolang=de [QSA,L]
RewriteRule ^de/bestellschein$ /order-slip.php?isolang=de [QSA,L]
RewriteRule ^de/kennwort-wiederherstellung$ /password.php?isolang=de [QSA,L]
RewriteRule ^de/angebote$ /prices-drop.php?isolang=de [QSA,L]
RewriteRule ^de/suche$ /search.php?isolang=de [QSA,L]
RewriteRule ^de/sitemap$ /sitemap.php?isolang=de [QSA,L]
RewriteRule ^de/shops$ /stores.php?isolang=de [QSA,L]
RewriteRule ^de/zulieferer$ /supplier.php?isolang=de [QSA,L]
RewriteRule ^de/([^?&]*) /$1?isolang=de [QSA,L]
RewriteRule ^it/pagina-non-trovata$ /404.php?isolang=it [QSA,L]
RewriteRule ^it/indirizzo$ /address.php?isolang=it [QSA,L]
RewriteRule ^it/indirizzi$ /addresses.php?isolang=it [QSA,L]
RewriteRule ^it/autenticazione$ /authentication.php?isolang=it [QSA,L]
RewriteRule ^it/vendite-migliori$ /best-sales.php?isolang=it [QSA,L]
RewriteRule ^it/carrello$ /cart.php?isolang=it [QSA,L]
RewriteRule ^it/contattaci$ /contact-form.php?isolang=it [QSA,L]
RewriteRule ^it/sconto$ /discount.php?isolang=it [QSA,L]
RewriteRule ^it/ospite-monitoraggio$ /guest-tracking.php?isolang=it [QSA,L]
RewriteRule ^it/storico-ordine$ /history.php?isolang=it [QSA,L]
RewriteRule ^it/identite$ /identity.php?isolang=it [QSA,L]
RewriteRule ^it/produttori$ /manufacturer.php?isolang=it [QSA,L]
RewriteRule ^it/il-mio-account$ /my-account.php?isolang=it [QSA,L]
RewriteRule ^it/nuovi-prodotti$ /new-products.php?isolang=it [QSA,L]
RewriteRule ^it/ordine$ /order.php?isolang=it [QSA,L]
RewriteRule ^it/seguito-ordine$ /order-follow.php?isolang=it [QSA,L]
RewriteRule ^it/ordine-veloce$ /order-opc.php?isolang=it [QSA,L]
RewriteRule ^it/nota-di-ordine$ /order-slip.php?isolang=it [QSA,L]
RewriteRule ^it/password-recupero$ /password.php?isolang=it [QSA,L]
RewriteRule ^it/riduzione-prezzi$ /prices-drop.php?isolang=it [QSA,L]
RewriteRule ^it/cerca$ /search.php?isolang=it [QSA,L]
RewriteRule ^it/sitemap$ /sitemap.php?isolang=it [QSA,L]
RewriteRule ^it/negozi$ /stores.php?isolang=it [QSA,L]
RewriteRule ^it/fornitore$ /supplier.php?isolang=it [QSA,L]
RewriteRule ^it/([^?&]*) /$1?isolang=it [QSA,L]
</IfModule>

# Catch 404 errors
ErrorDocument 404 /404.php

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/javascript "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType application/x-javascript "access plus 1 week"
    ExpiresByType image/x-icon "access plus 1 year"
</IfModule>

FileETag INode MTime Size
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

Thanks for your help.

share|improve this question
    
Apache decode URL by default. What does your configuration file look like? –  quanta Oct 4 '11 at 10:34
    
I updated my post with more details. I also updated the path to the image from the / url, in order for you to see that the .htaccess doesn't have any action on that urls (from what I saw) –  Cyril N. Oct 4 '11 at 11:01
1  
First off, %20 was converted to space just fine in the log line you pasted. Secondly, the log is always going to encode anything that isn't printable ASCII in order to foil control character attacks. Finally, what character set is your system using? The log looks like perfectly fine UTF-8 (where LATIN SMALL LETTER E WITH ACUTE is encoded as C3 A9 in hex). –  DerfK Oct 4 '11 at 12:14
    
Ok good to know. I just tried AddDefaultCharset UTF-8, ISO-8859-1 AND ISO-8859-15, nothing changed :/ –  Cyril N. Oct 4 '11 at 12:22
    
Ok I found the problem (but now I need to fix it and I don't know how). that's the files on my system that are badly encoded, with "Certifi� AB.jpg". –  Cyril N. Oct 4 '11 at 12:31
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.