How to redirect /post-name to /post/post-name?

by mallory_cormier , in category: Third Party Scripts , 6 months ago

How to redirect /post-name to /post/post-name?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by daisha , 6 months ago

@mallory_cormier 

You can redirect the URL /post-name to /post/post-name by adding a RewriteRule in the .htaccess file of your website. Here's an example of how you can do this:

  1. Open the .htaccess file in the root directory of your website using a text editor.
  2. Add the following line of code to create the redirect:
1
2
RewriteEngine On
RewriteRule ^post-name$ /post/post-name [R=301,L]


  1. Save the .htaccess file and upload it back to your server.


With this rule in place, any requests for /post-name will be redirected to /post/post-name. The 301 status code indicates that this is a permanent redirect, which can be beneficial for search engine optimization to ensure that the new URL is properly indexed.

Related Threads:

How to redirect all post requests via .htaccess?
How to redirect user with post data in react.js?
How to redirect post request to another route in node.js?
How to send post data and redirect in node.js?
How to redirect existing post url after changing slug in wordpress?
How to validate post request in symfony 5?