• Plans & Pricing
  • Log in
  • Get started
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress 
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Get started
  • Sign up
  • Log in
About
  • Plans & Pricing
Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress  
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Jetpack App
  • Learn more
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Search
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Forums / wordpress custom redirection

wordpress custom redirection

  • Unknown's avatar
    bsastre85f635cb4f · Member · Jan 25, 2024 at 1:23 am
    • Copy link Copy link
    • Add topic to favorites Add topic to favorites

    Greetings!

    We currently have a wordpress blog with a translation plugin that we don’t like at all. We are switching to WPML. The issue is that the actual bad plugin has translated all the posts with language code in the url like this:

    /es_ES/ for spanish
    /en_US/ for english
    /pt_BR/ for portuguese

    and the WPML plugin uses a different code languages:

    /es/ for spanish
    (nothing) for english, because is the default language on my site
    /pt/ for portuguese

    WPML does allows to create custom languages, so we could create variations for those languages, and create our own language codes that match the actual/old plugin, but I am thinking that it might be a better or more elegant solution to use the default WPML codes, and just redirect the old URL’s to the new ones.

    So, for example, let’s say a user enters an old url for a post:

    https://genexus.blog/es_ES/genexus-platform/18-news-about-genexus-18/

    I would like to create a custom redirection rule that redirects the user in this case, to the same url, but modifying the code part only, to martch WPML code:

    https://genexus.blog/es/genexus-platform/18-news-about-genexus-18/

    So what I did is ask chat-gpt to give me a .htaccess redirect rule:

    RewriteRule ^(.*)/es_ES/(.*)$ $1/es/$2 [R=301,L]

    This didn’t work. When I tried to go to :

    https://genexus.blog/es_ES/genexus-platform/18-news-about-genexus-18/

    WordPress redirected to me to the default post url, with is english :

    18 news about GeneXus 18

    I then asked WPML support if the plugin was may be doing some kind of custom redirection, and they told me that it could be WordPress. I did some Google and find out that WordPress has some redirection functions like this ones:

    • redirect_canonical()
    • redirect_guess_404_permalink()

    The first one is very important for SEO, and disabling this function could hurt the blog SEO.

    The recomendation seems to be to disable the other function: redirect_guess_404_permalink()

    redirect_guess_404_permalink() is a function that looks for similar URLs registered in WordPress and will redirect old URLs to those it can find. This feature is nice to have for SEO if you are not keeping an eye on your 404 pages but can create some weird redirect behavior. That might be why you found this post interesting… you need your redirects to be more predictable.

    https://typerocket.com/disable-wordpress-automatic-or-random-redirect-guessing-of-404s/

    But then I thougt, may be, instead of disabling that function, and doing my custom redirect on .htacess, I could use WordPress to create my custon redirection, and forget about tweaking .htacces

    So, to round up, my question is: Can I customize redirect_guess_404_permalink() function to do what I need? That is, redirect my current urls /es_ES/ to my new urls /es/.

    If that is possibe, I would appreciate any techy Wordpres developer to shed some light on me.

    Thanks in advance.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar
    staff-totoro · Staff · Jan 30, 2024 at 11:23 pm
    • Copy link Copy link

    Hi there,

    One thing to be aware of is that unlike other hosts (most hosts?) we do not use Apache web servers, which is the kind of web server that uses .htaccess files. This is why the code provide by GPT will not work for your site.

    Instead we use a custom managed hosting environment (based on nginx) that is optimized for the needs of WordPress. It’s not possible to edit the .htaccess file (we don’t use them) and it is also not possible to set up redirects at the server level.

    However, the good news is that you can instead use a redirection plugin to help you manage our redirects, and from what I understand most plugins that I’ve seen will let you use regular expressions as well.

    https://wordpress.com/plugins/?s=redirection

    Hope that helps. Please let us know if you have any more questions.

  • The topic ‘wordpress custom redirection’ is closed to new replies.

Tags

  • account
  • currency
  • design
  • import
  • Jetpack

About this topic

  • In: Support
  • 2 participants
  • 1 reply
  • Last activity 2 years
  • Latest reply from bsastre85f635cb4f

Couldn't find what you needed?

Contact us

Contact us

Get answers from our AI assistant, with access to 24/7 expert human support on paid plans.

Browse our guides

Browse our guides

Find step-by-step solutions to common questions in our comprehensive guides.

WordPress.com

Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Professional Email
  • Website Design Services
  • WordPress Studio
  • Enterprise WordPress
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • WordPress.com Blog
  • Business Name Generator
  • Logo Maker
  • WordPress.com Reader
  • Accessibility
  • Remove Subscriptions
Help
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
  • Developer Resources
Company
  • About
  • Press
  • Terms of Service
  • Privacy Policy
  • Do Not Sell or Share My Personal Information
  • Privacy Notice for California Users
DeutschEspañolFrançaisBahasa IndonesiaItalianoNederlandsPortuguês do BrasilSvenskaTürkçeРусскийالعربيةעִבְרִית日本語한국어简体中文繁體中文English

Mobile Apps

  • Download on the App Store
  • Get it on Google Play

Social Media

  • WordPress.com on Facebook
  • WordPress.com on X (Twitter)
  • WordPress.com on Instagram
  • WordPress.com on YouTube

Automattic

Automattic
Work With Us
    • WordPress.com Forums
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions