Redirection PHP ou htaccess

Fermé
Vitaly58 Messages postés 43 Date d'inscription samedi 2 avril 2011 Statut Membre Dernière intervention 15 novembre 2012 - 24 sept. 2012 à 16:42
 Utilisateur anonyme - 25 sept. 2012 à 03:44
Bonjour,

Je souhaiterais rediriger un grand nombre de liens ayant la même structure (côté serveur) en remplaçant simplement les - par des +

Exemples :

La page :
http://www.monsite.com/site/search/?phrase=samsung-dvd&where=&isNewSearch=true&categoryId=0&go.x=0&go.y=0

Doit rediriger vers :
http://www.monsite.com/site/search/?phrase=samsung+dvd&where=&isNewSearch=true&categoryId=0&go.x=0&go.y=0

La page :
http://www.monsite.com/site/search/?phrase=billets-avion-thailande&where=&isNewSearch=true&categoryId=0&go.x=0&go.y=0

Doit rediriger vers :
http://www.monsite.com/site/search/?phrase=billets+avion+thailande&where=&isNewSearch=true&categoryId=0&go.x=0&go.y=0

Il s'agit simplement de remplacer les caractères - par des + pour les mots inclus dans le paramètre "phrase".

Je ne sais pas si on peut faire une redirection htaccess ou une redirection PHP.

Voici mon htaccess actuel :
#Put the line here to enable PHP5

SetEnv PHP_VER 5

#You may need to un-comment the following line
#Options +FollowSymlinks

# REMEBER YOU ONLY NEED TO STARD MOD REWRITE ONCE
RewriteEngine On

#REWRITE BASE
#RewriteBase /

# HERE IS A GOOD PLACE TO ADD THE WWW PREFIXE REDIRECTION

# HERE IS A GOOD PLACE TO ADD THE OLD SCRIPT REDIRECTION
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php
RewriteEngine on
RewriteOptions inherit


Est-ce que quelqu'un sait comment faire ?

Merci

A voir également:

1 réponse

Utilisateur anonyme
25 sept. 2012 à 03:44
Voici une piste en php:

$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$newurl = str_replace ( "-", "+" , $url )

header("Location:".$newurl)
0