Redirection Free vers .fr (pages différentes et phpBB)

Nouveau WRInaute
Bonjour à tous !
Ceci est mon premier message car j'ai toujours trouvé les solutions à mes problèmes mais aujourd'hui j'ai du mal à trouver une solution.

Voici la situation :
Comme beaucoup je passe d'un hébergement page perso de free.fr vers un nom de domaine en .fr (disons exemple.fr). J'ai actuellement un forum phpBB2 sur le Free et le nouveau site sera basé sur une autre arborescence (WordPress). Je souhaite faire une redirection 301 de chaque page chez Free vers le nouveau site (ce sera long mais c'est la meilleure solution que j'ai trouvée :mrgreen: )

Petit détail : mon forum est dans un sous-dossier /phpBB2/ et le .htaccess est dans ce même dossier (il est déplaçable), il contient "php 1" pour évier l'erreur 500 de free.

J'ai essayé :
Code:
RedirectPermanent /phpBB2/viewtopic.php?t=110 http://exemple.fr/nouvelle-page/
Mais ça ne fonctionne pas... (j'ai testé un peut tout : Redirect 301, .htaccess à la racine, ...).
Les outils d'analyse d'entête php ne voit pas cette commande.

Pour info : un RedirectPermanent / http://exemple.fr/ fonctionne très bien. C'est vraiment l'url qui semble poser problème.


Avez-vous une solution ?
Merci beaucoup :D
 
Nouveau WRInaute
Donc, comme lu ICI le point d'interrogation semble poser problème.
L'url rewriting est inévitable SAUF si on n'utilise pas le .htaccess

Il faut utiliser ce code (à mettre tout en haut de viewtopic.php) :
Code:
if ($_SERVER[argv][0]=='t=110') {
header('HTTP/1.1 301 Moved Permanently', false, 301);
header('Location: http://jacknumber.fr/');
exit();}
source

Et si comme moi vous avez plusieurs redirections différentes à faire, utilisez ce code que j'ai modifié avec un switch :
Code:
switch($_SERVER[argv][0]){
	case 't=110':
		header('HTTP/1.1 301 Moved Permanently', false, 301);
		header('Location: http://jacknumber.fr/');
		exit();
		break;
	case 't=123':
		header('HTTP/1.1 301 Moved Permanently', false, 301);
		header('Location: http://monsite.fr/');
		exit();
		break;
	//etc...
}

Voilà !
 
Nouveau WRInaute
Désolé pour le déterrage, j'ai des remarques en MP donc j'améliore mon code :

Code:
switch($_GET['t']){
	case 110:
		$new_url = 'awesome-url';
		break;
	case 123:
		$new_url = 'incredible-url';
		break;
	default:
		$new_url = '';
}

header('HTTP/1.1 301 Moved Permanently', false, 301);
header('Location: http://monsite.fr/' . $new_url);
exit();
 
WRInaute accro
Bah vire le switch car c'est lourd autant que moche :

PHP:
<span class="syntaxdefault">$newurl</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">714</span><span class="syntaxkeyword">]=</span><span class="syntaxstring">'http://www.example.com/libye.php'</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">$newurl</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">715</span><span class="syntaxkeyword">]=</span><span class="syntaxstring">'http://www.example.com/liechtenstein.php'</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">$newurl</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">716</span><span class="syntaxkeyword">]=</span><span class="syntaxstring">'http://www.example.com/lituanie.php'</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">$newurl</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">717</span><span class="syntaxkeyword">]=</span><span class="syntaxstring">'http://www.example.com/luxembourg.php'</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">$newurl</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">718</span><span class="syntaxkeyword">]=</span><span class="syntaxstring">'http://www.example.com/macao.php'</span><span class="syntaxkeyword">;<br />....<br /><br /></span><span class="syntaxdefault">header</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"HTTP/1.1 301 Moved Permanently"</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">header</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Location: "</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$newurl</span><span class="syntaxkeyword">[(int)</span><span class="syntaxdefault">$_GET</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'t'</span><span class="syntaxkeyword">]]);<br />exit;</span><span class="syntaxdefault"></span>
 
Nouveau WRInaute
J'ai utilisé un switch car je souhaitais passer d'autres paramètres en GET/POST. Mais, oui, pour ce cas ton tableau est plus efficace.

Merci ;)
 
Discussions similaires
Haut