SHARE
TWEET

Force lowercase .htaccess

a guest Apr 10th, 2012 59 Never
  1. RewriteEngine On
  2. RewriteMap  lc int:tolower
  3. RewriteCond %{REQUEST_URI} [A-Z]
  4. RewriteRule (.*) ${lc:$1} [R=301,L]
  5.        
  6. /home/public_html/.htaccess: RewriteMap not allowed here
  7. [Mon Jul 18 10:33:06 2011] [alert] [client *.*.*.*] /home/public_html/.htaccess: RewriteMap not allowed here
  8.        
  9. $url = $_SERVER['REQUEST_URI'];
  10. $pattern = '/([A-Z]+)/';
  11.  
  12. if(preg_match($pattern, $url)) {
  13.     $new_url = strtolower($url);
  14.  
  15.     Header( 'HTTP/1.1 301 Moved Permanently' );
  16.     Header( 'Location: ' . $new_url );
  17.     exit;
  18. }
  19.  
  20. // your code here
RAW Paste Data
Top