• Resolved riyazmuhammad

    (@riyazmuhammad)


    Hi,

    I am using wpglobus plugin for translating my website to arabic. my URL is like blog.example.com ( subdomain ) and wpglobus working perfectly on this. But I should have to change the URL to example.com/blog ( subdirectory ). I used htaccess rules for this. Then english is working fine and arabic not working. when I inspect the language change button it still shows old URL ( subdomain ). I am using below code for language change:

    <?php 
              if ( class_exists( 'WPGlobus' ) ) {
          echo '<div class="wpglobus-selector-box">';
            foreach( WPGlobus::Config()->enabled_languages as $lang ) {
    
              if ( $lang == WPGlobus::Config()->language ) {
                continue;
              }
              echo '<a href="' . WPGlobus_Utils::localize_current_url( $lang ). '">';
              echo WPGlobus::Config()->language_name[ $lang ];
              echo '</a>';
    
            }
          echo '</div><!-- .wpglobus-selector-box -->';
        }
            ?>

    How can I change the subdomain URL to subdirectory on this code? Please help

Viewing 1 replies (of 1 total)
  • Plugin Contributor Alex Gor

    (@alexgff)

    Try this code

    
    <?php 
    	if ( class_exists( 'WPGlobus' ) ) {
    		echo '<div class="wpglobus-selector-box">';
            foreach( WPGlobus::Config()->enabled_languages as $lang ) {
    
    			if ( $lang == WPGlobus::Config()->language ) {
    				continue;
    			}
    			$url = set_url_scheme( 'https://' . $_SERVER['HTTP_HOST'] . '/blog' . $_SERVER['REQUEST_URI'] );	
    			
    			echo '<a href="' . $url. '">';
    			echo WPGlobus::Config()->language_name[ $lang ];
    			echo '</a>';
    
            }
          echo '</div><!-- .wpglobus-selector-box -->';
        }
    ?>
    
Viewing 1 replies (of 1 total)
  • The topic ‘multilingual not working when URL redirection’ is closed to new replies.