Mod_rewrite with UTF-8 accent, multiviews , .htaccess

Posted by GuruJR on Server Fault See other posts from Server Fault or by GuruJR
Published on 2012-04-06T16:08:03Z Indexed on 2012/04/06 17:32 UTC
Read the original article Hit count: 326

Filed under:
|
|
|

Problem: with Mod_rewrite, multiview & Apache config

Introduction: The website is in french and i had problem with unicode encoding and mod_rewrite within php wihtout multiviews

  • Old server was not handling utf8 correctly (somewhere between PHP, apache mod rewrite or mysql)
  • Updated Server to Ubuntu 11.04 , the process was destructive
    • lost all files in var/www/ (the site was mainly 2 files index.php & static.php)
    • lost the site specific .Htaccess file
    • lost MySQL dbs
    • lost old apache.conf

What i have done so far:

What works:

  • Setup GNutls for SSL, Listen 443 => port.conf
  • Created 2 Vhosts in one file for :80 and :443 => website.conf
  • Enforce SSL => Redirecting :80 to :443 with a mod_rewrite redirect
  • Tried to set utf-8 everywhere.. Set charset and collation , db connection , mb_settings , names utf-8 and utf8_unicode_ci, everywhere (php,mysql,apache)
  • to be sure to serve files as UTF-8 i enabled multiview
  • renamed index.php.utf8.fr and static.php.utf8.fr
  • With multiview enabled, Multibytes Accents in URL works
  • SSL TLS 1.0

What dont work:

  • With multiview enabled , mod_rewrite works for only one of my rewriterules
  • With multiview Disabled, i loose access to the document root as "Forbidden"
  • With multiview Disabled, i loose Multibytes (single charater accent)
  • The Apache Default server is full of settings. (what can i safely remove ?)

these are my configuration files so far

:80 Vhost file (this one work you can use this to force redirect to https)

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
LanguagePriority fr

:443 Vhost file (GnuTls is working)

DocumentRoot /var/www/x
ServerName example.com 
ServerAlias www.example.com
<Directory "/var/www/x">
 allow from all                             
 Options FollowSymLinks +MultiViews  
 AddLanguage fr .fr   
 AddCharset UTF-8 .utf8 
 LanguagePriority fr
</Directory>
GnuTLSEnable on                             
GnuTLSPriorities SECURE:+VERS-TLS1.1:+AES-256-CBC:+RSA:+SHA1:+COMP-NULL
GnuTLSCertificateFile /path/to/certificate.crt
GnuTLSKeyFile /path/to/certificate.key
<Directory "/var/www/x/base">
</Directory>

Basic .htaccess file

 AddDefaultCharset utf-8
 Options FollowSymLinks +MultiViews
 RewriteEngine on
 RewriteRule ^api/$  /index.php.utf8.fr?v=4  [L,NC,R]
 RewriteRule ^contrib/$ /index.php.utf8.fr?v=2  [L,NC,R]
 RewriteRule ^coop/$  /index.php.utf8.fr?v=3  [L,NC,R]
 RewriteRule ^crowd/$  /index.php.utf8.fr?v=2  [L,NC,R]
 RewriteRule ^([^/]*)/([^/]*)$ /static.php.utf8.fr?VALUEONE=$2&VALUETWO=$1 [L]

So my quesiton is whats wrong , what do i have missing is there extra settings that i need to kill from the apache default . in order to be sure all parts are using utf-8 at all time, and that my mod_rewrite rules work with accent

Thank you all in advance for your help, I will follow this question closely , to add any needed information.

© Server Fault or respective owner

Related posts about apache2

Related posts about .htaccess