Support » Plugin: Safe Redirect Manager » How to redirect to

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Daniel Bachhuber


    Hand Built

    You could do something based on the ‘lang’ param (untested):

    add_action( 'template_redirect', 'dbx_redirect_lang' );
    function dbx_redirect_lang() {
    	if ( ! is_single() )
    	if ( ! empty( $_GET['lang'] ) && in_array( $_GET['lang'], array( 'fr', 'es' ) )
    		wp_safe_redirect( $_GET['lang'] . '/' . get_query_var( 'postname' ) );
    		wp_safe_redirect( 'en/' . get_query_var( 'postname' ) );

    This wouldn’t need the plugin at all. You’d want to make sure it only executed for the main site though.

    Thanks Daniel but I would not use php modification if possible.


    Plugin Contributor Daniel Bachhuber


    Hand Built

    I think the PHP approach is best for this situation.

    Hi Daniel,

    Maybe but as a consultant in application quality (look at my blog, I tend to minimize customization as much as possible.

    Not that it cannot be done correctly, but to do it correctly in this case means a theme child, a good knowledge not only of PHP but of WP APIs and there is always the risk that a plugin will conflict with your own development. Furthermore, you have to maintain your own code in the future.

    So I believe that this is more effort than it is worth in my case. I have been doing a 301 redirection from all the whichever the ?/lang= parameter, to the english page
    Not the most precise, but as I updated the internal links (to the correct page according to the language), the redirection is only for the external search.

    I will close this topic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to redirect to’ is closed to new replies.