Created
April 13, 2021 11:55
-
-
Save moskalukigor/b160ed08b78f3e1314a8b57f39c2ed64 to your computer and use it in GitHub Desktop.
q-Translate remove 302 redirect. Need to overwrite qtranslate_core.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$target = apply_filters( 'qtranslate_language_detect_redirect', $url_lang, $url_orig, $url_info ); | |
if ( $target !== false && $target != $url_orig ) { | |
//Custom code Start | |
$urlToArray = explode('/', $url_orig); | |
if(end($urlToArray) != "") | |
{ | |
$target .= '/'; | |
} | |
//Custom code End | |
wp_redirect( $target , 301); | |
nocache_headers(); // prevent browser from caching redirection | |
exit(); | |
} else { | |
// neutral path | |
$url_info['doredirect'] .= ' - cancelled, because it goes to the same target - neutral URL'; | |
if ( $pagenow == 'index.php' && $q_config['url_mode'] == QTX_URL_PATH ) { | |
$_SERVER['REQUEST_URI'] = trailingslashit( $url_info['path-base'] ) . $lang . $url_info['wp-path']; // should not hurt? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment