S
S
speculant2018-12-13 05:35:49
htaccess
speculant, 2018-12-13 05:35:49

Wordpress redirects to the profile page do not work if the nickname does not consist of numbers, how to solve?

Hello, problem with wordpress redirects
Made a profile page with my own template.
It is necessary that when you go to the site / profile / "whatever", the created page with the profile template opens.
It works for me only if you enter numbers, with ordinary nicknames it works only through a dynamic parameter
How to solve this problem?
Tried to add different rules to .htaccess via template function
for example:

function do_rewrite(){ 
add_rewrite_rule( '^(profile)/([^/]*)/?', '?nick=$matches[1]', 'top' );
 }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy Orlov, 2018-12-14
@orlov0562

function do_rewrite(){ 
    add_rewrite_rule( '^profile/([^/]+)/?', '?nick=$matches[1]', 'top' );
 }

When /profile/abc is requested, it will redirect to /?nick=abc
Well, do not forget that you need to do_rewrite in add_action And then re-save the paths in the admin panel so that .htaccess is rewritten
Select Settings -> Permalinks and just click Save Changes without any changes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question