sharingsunshine
asked on
Need Help Making Destination Url Lower Case
Regex Destination url needs to be lower case. I found this code that will convert it to lower case in the httpd.conf file.
Here is a sample url
I need to know if there is a better way to do this. Because it seems very slow on Xampp.
RewriteMap lc int:tolower
RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]
Here is a sample url
http://www.theherbsplace.com/Garlic_Oil_Capsules_p_400.html
source urlhttps://www.theherbsplace.com/product/garlic_oil_capsules_p_400/
target urlI need to know if there is a better way to do this. Because it seems very slow on Xampp.
ASKER
I found this one
but I couldn't make it work. Do you have any suggestions?
<?php
if(isset($_GET['rewrite-strtolower-url'])) {
$url = $_GET['rewrite-strtolower-url'];
unset($_GET['rewrite-strtolower-url']);
$params = http_build_query($_GET);
if(strlen($params)) {
$params = '?' . $params;
}
// if you don't have SSL/a security certificate at the destination change https:// to http:// below
header('Location: https://' . $_SERVER['HTTP_HOST'] . '/' . strtolower($url) . $params, true, 301);
exit;
}
header("HTTP/1.0 404 Not Found");
die('Unable to convert the URL to lowercase. You must supply a URL to work upon.');
but I couldn't make it work. Do you have any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you change the RewriteRule to use "rewrite-strtolower-url" instead of "page"?
ASKER
yes, I did and I got it to work but it is very slow. I tried the other script and it is 10X faster.
ASKER
Thanks for the help.
Open in new window
I don't recall ever using RewriteMap myself.