Really dynamic routes in WordPress

Question

My customer asked me to implement really dynamic URL rewriting for WordPress site to looks like https://cpkrus.ru.
Shown URL depends not on previously entered URL (regex), but based on context – whether city defined or not.
Rule set is the following:

Regex-way here is not applicable here – because add_rewrite_* doesn’t know about city which is not in url.

Laravel-way is most applicable here – when destination pointed exactly or determined additionally by some handler (dynamic behavior).

It would best in WordPress to have something like:

Route::post('/', function($source) {
    // analyze context - city defined or not (not in URL!)
    $targetQuery = '...';
    return $targetQuery;
});

Is it possible to do something similar to this dynamic approach?

0
Valery Bulash 2 years 2020-10-25T09:10:36-05:00 0 Answers 8 views 0

Leave an answer

Browse
Browse