Page 1 of 1

Route with dashes in URL

Posted: Tue Oct 24, 2017 11:39 pm
by bzark
I have been running OpenCart 2.1.0.2 for years and I am in the process of upgrading to version 2.3.0.2. I have successfully upgraded and I am slowly adding in all my extensions and theme. The only thing I have added back in so far is my custom theme. The issue I am seeing is that I have marketing pages on my site and they use dashes in the route

Code: Select all

index.php?route=xyz-123/test
and on the web server I have

Code: Select all

catalog/controller/xyz-123/test.php
. When I navigate to that link I get the 404 not found page. This worked find in 2.1.0.2.

Does anyone know if there was a change made so that dashes are not permitted in the URL's route?

Re: Route with dashes in URL

Posted: Wed Oct 25, 2017 11:43 pm
by bzark
Just in case anyone is interested in the fix for this. The following code (in a bunch of places) throws away the "dash". Just add the "-" to the regular expression and it will work.

Code: Select all

$route = preg_replace('/[^a-zA-Z0-9_\/]/', '', (string)$route);
This isn't the complete solution but I don't have time at the moment to write it up. I am subscribed to the thread so if anyone in the future does need the complete fix, reply to this thread and I will be notified.

Re: Route with dashes in URL

Posted: Wed Oct 25, 2017 11:54 pm
by webcorvo
Hi,

Can you give us the url of your shop?

Re: Route with dashes in URL

Posted: Thu Oct 26, 2017 12:00 am
by webcorvo
on the config.php file you must have:

define('DIR_TEMPLATE', 'server_path/catalog/view/theme/');

Re: Route with dashes in URL

Posted: Thu Oct 26, 2017 12:08 am
by bzark
webcorvo wrote:
Thu Oct 26, 2017 12:00 am
on the config.php file you must have:

define('DIR_TEMPLATE', 'server_path/catalog/view/theme/');
That isn't the issue. I have that in my config.php file.