php - How to redirect a page that does not exist anymore in Wordpress? -


when first made wordpress site didn't know it's idea use slugs instead of ids in links. had page had address:

http://example.com/?page_id=50 

when made template popular e-commerce platform in country included said link. year later site crashed , had rebuild it. needless say, page in question assigned different id. cannot change on e-commerce platform (that require thousands of individual changes - not overstatement).

so, can somehow redirect /?page_id=50 different page? problem no page has particular id.

is there way? tried .htaccess redirection didn't work or maybe did wrong. wrote

redirect /?page_id=50 http://example.com/page-slug/ 

in .htaccess

i tried (as suggested below):

# begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule>  # end wordpress  rewriteengine on rewritecond %{query_string} (^|&)page_id=50($|&) rewriterule . http://example.com/page-slug/? [r=301,l] 

as as:

# begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] rewritecond %{query_string} (^|&)page_id=50($|&) rewriterule . http://lucart.pl/lucart-w-radio-eska/? [r=301,l]  </ifmodule>  # end wordpress 

neither worked :(

please help.

please add redirection php code @ top of theme header.php template before html started:

$request_url = 'http://'.$_server['server_name'].$_server['request_uri'];     if($request_url=='http://example.com/?page_id=50'){         wp_redirect('http://example.com/page-slug/ ');     } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -