• Resolved Natalie


    A couple of years ago being in haste and without considering the issue with due attention, I created random permanent links /news/111%post_id%.html
    Now articles at my website are displayed in the following way: mysite.com/news/11111385.html
    It’s not a good-looking link.

    I would like to replace it with /%postname%-%post_id%.html to get mysite.com/primer-123.html

    On the website there are 1300 pages, and other online resources cite most of them and provide hyperlinks to them. I do not want to redirect each page manually as it is quite a complicated and time-consuming task.

    So my question is: how to replace the link correctly and redirect old articles to the new address, so that they would not be lost from the index and visitors from other websites would not stumble upon page 404?

    Is it possible to automatically redirect all the news from /news/111%post_id%.html to /%postname%-%post_id%.html?

    What should I write in .htaccess in this case?
    RewriteEngine On
    RewriteRule ……………

    WordPress version 4.6

Viewing 2 replies - 1 through 2 (of 2 total)
  • There is no other way I could find other than to redirect each link individually. That way, if anyone had a page bookmarked, or one of the old links is referenced elsewhere, you can be sure that there will be a redirect to the new URL. It would be nice if there were a faster way, but individual redirects seem to be the safest bet.

    It would look like this in your .htaccess file:

    Redirect 301 /oldfile.htm /newfile

    • This reply was modified 7 years, 9 months ago by stanordan.
    Thread Starter Natalie


    Thank you for your kind reply! As it turned out, you are not quite right. There is a solution, and I’ve already used it successfully.
    In .htaccess before # BEGIN WordPress I wrote the following:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/news/111(\d+)\.html
    RewriteRule . /index.php?p=%1 [L]

    This code was created for my case by a Russian guy (many thanks to him). Perhaps someone may need it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to correctly change URL? Redirect old links to the new ones’ is closed to new replies.