Do you have access to the httpd.conf file or do you only have .htaccess file access?
No, I don't have access to the httpd.conf file.
Then you will need a PHP script as well
Code:Options +FollowSymLinks RewriteEngine On RewriteRule ^([^/]*[a-z][^/]*)(/.*)?$ /script.php?dir=$1&rest=$2 [QSA,L](Untested.)PHP Code:
if(getenv('REDIRECT_STATUS') === false || !isset($_GET['dir'])
|| empty($_GET['dir']) || !isset($_GET['rest']))
# The request was not processed by mod_rewrite.
header('Location: http://' . getenv('HTTP_HOST') . '/', true, 301);
$redirect = strtoupper($_GET['dir']) . $_GET['rest'];
$query_string = getenv('QUERY_STRING');
$redirect .= '?' . $query_string;
header('Location: http://' . getenv('HTTP_HOST') . '/' . $redirect, true, 301);
Thanks for the info but I must be doing something wrong.
I put the script in the root dir & added the above to the htaccess file but it doesn't uppercase the dir.
If you put the following mod_rewrite in your .htaccess file
and go to http://example.com/Google, do you get redirected to Google?Code:Options +FollowSymLinks RewriteEngine On RewriteRule Google http://www.google.com/? [NC,R,L]
No, It didn't redirect.
If you haven't got htaccess with mod rewrite enabled which it seems you haven't Then the only thing i can think that you can do is have two folders in your document root one with capitals and one without. Which will suck if you have lots of PHP files to redirect from. But if its just one index file might not be so bad. Well will still suck but. And this is the index file you would put in the lower case folder.
But again this sucks. It would work on linux server but not on a windows server. Because windows you can't have a lower and upper case version of the folders. Anyway if it was me I would contact your server host and ask about mod rewrite.PHP Code:
$url = $_SERVER["PHP_SELF"];
$url_folders = explode ('/', ltrim($url, "/"));
$url_folders = strtoupper($url_folders);
$url_folders = "/". implode('/', $url_folders);
$qs = "";
$qs = "?". $_SERVER["QUERY_STRING"];
$domain = $_SERVER["SERVER_NAME"];
header('Location: http://' . $domain . $url_folders . $qs);
Last edited by timgolding; 04-18-2009 at 12:15 AM.
You can not say you know how to do something, until you can teach it to someone else.
You can use a custom 404 handler instead.
andCode:ErrorDocument 404 /404handler.php
$request_uri = getenv('REQUEST_URI');
# Does the first directory contain a lower case letter?
if(preg_match('~^/([^/]*[a-z][^/]*)(/(.*))?$', $request_uri, $matches))
# Make the first directory upper case.
$first_directory = strtoupper($matches);
# Does the directory exist?
if(is_dir(getenv('DOCUMENT_ROOT') . '/' . $first_directory))
# Redirect to the upper case directory.
header('Location: http://' . getenv('HTTP_HOST') . '/' . $first_directory . '/' . $matches, true, 301);
Normal 404 page here.
Thanks to everyone for the help.
The 404 redirect worked Great!!!