shaggytail Posted January 10, 2023 Share Posted January 10, 2023 Hi, we're running into an issue where both lowercase and uppercase versions of our urls are being indexed Example a): website.com/hello/this-URL/ Example: b) website.com/hello/this-url/ This occurred because some of our content was linking to example A. We have since corrected all internal links within our website to link to example B. According to some research, this is often done via apache settings but our website uses case sensitive files "exAmple.jpg" "formCustomer.php" so doing that would make these files invalid. Overhauling our website to satisfy the apache fix would require many many man hours. Is there a way to do this within Processwire's core, something like strtolower urls then proceed. Thanks. Been a ProcessWire user for 7 years I love it, use it daily. Link to comment Share on other sites More sharing options...
shaggytail Posted January 10, 2023 Author Share Posted January 10, 2023 So far I've tried to make a hook using Page::url, Page::path, wireHttp::, session::, none of which worked. Link to comment Share on other sites More sharing options...
shaggytail Posted January 10, 2023 Author Share Posted January 10, 2023 $this->addHookBefore('ProcessPageView::execute', function(HookEvent $event) { // Get the object the event occurred on, if needed $process = $event->object; $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; echo $process->getPage()->httpUrl; if($actual_link !== $process->getPage()->httpUrl) { header("HTTP/1.1 301 Moved Permanently"); header("Location: ". $process->getPage()->httpUrl); exit(); } }); This is what I ended up implementing, not sure if it's the proper way but it works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now