Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Serveurs (Apache, IIS,...) > Apache
Apache Forum d'entraide Apache. Avant de poster : Cours Apache, FAQ Apache
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 04/02/2011, 16h50   #1
Invité de passage
 
Kurios ETHER
Inscription : septembre 2010
Messages : 4
Détails du profil
Informations personnelles :
Nom : Kurios ETHER

Informations forums :
Inscription : septembre 2010
Messages : 4
Points : 3
Points : 3
Par défaut [URL rewriting] multi-domaine et sous-répértoires

Bonjour,

Voici ma situation : un hébergement chez OVH, 3 nom de domaines, deux sites et beaucoup de sous-sites mais sans véritables sous-domaines.

www.toutfaire.com pointe sur /www/
Là un .htaccess redirige de la manière suivante :

Code :
1
2
3
4
5
6
7
8
9
SetEnv PHP_VER 5
SetEnv REGISTER_GLOBALS 0

RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^FR$
RewriteRule ^(.*)$ http://www.toutfaire.fr$1 [L]
 
RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^BE$
RewriteRule ^(.*)$ http://www.toutfaire.be$1 [L]
Cela fonctionne, pas de soucis de ce côté.

www.toutfaire.fr pointe sur /www/drupal
www.toutfaire.be pointe sur /www/drupal

Sur /www/drupal j'ai un second htaccess qui a pour but de rediriger les sites adhérents (qui sont en html simple), par exemple :
www.toutfaire.fr/pmd est redirigé vers www.toutfaire.fr/adh_france/pmd

Mon souci :
J'ai deux adhérents ayant le même nom : un en france, un en belgique,
l'adhérent belge pointe aussi sur le français, lorsque l'on tape :
www.toutfaire.be/gilles on tombe systématiquement sur www.toutfaire.fr/adh_france/gilles au lieu de www.toutfaire.fr/adh_belgique/gilles

Comment puis-je les différencier ? (détection du .be ou du .fr)
Voici le htaccess :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  # There is no end quote below, for compatibility with Apache 1.3.
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php index.html

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /
  
  # Minisites adherents france
  RewriteRule ^3d(.*)$ http://www.toutfaire.fr/adh_france/3d$1 [P,L]
  RewriteRule ^aji-materiaux(.*)$ http://www.toutfaire.fr/adh_france/aji-materiaux$1 [P,L]
  RewriteRule ^amc(.*)$ http://www.toutfaire.fr/adh_france/amc$1 [P,L]
  RewriteRule ^aux-docks-de-clamart(.*)$ http://www.toutfaire.fr/adh_france/aux-docks-de-clamart$1 [P,L]
  RewriteRule ^baleydier(.*)$ http://www.toutfaire.fr/adh_france/baleydier$1 [P,L]
  RewriteRule ^barbezieux-materiaux(.*)$ http://www.toutfaire.fr/adh_france/barbezieux-materiaux$1 [P,L]
  RewriteRule ^bardusco(.*)$ http://www.toutfaire.fr/adh_france/bardusco$1 [P,L]
  RewriteRule ^bohnert(.*)$ http://www.toutfaire.fr/adh_france/bohnert$1 [P,L]
  RewriteRule ^boismat(.*)$ http://www.toutfaire.fr/adh_france/boismat$1 [P,L]
  RewriteRule ^bonnepart(.*)$ http://www.toutfaire.fr/adh_france/bonnepart$1 [P,L]
  RewriteRule ^bouteyves(.*)$ http://www.toutfaire.fr/adh_france/bouteyves$1 [P,L]
  RewriteRule ^bouvet-materiaux(.*)$ http://www.toutfaire.fr/adh_france/bouvet-materiaux$1 [P,L]
  RewriteRule ^clavel(.*)$ http://www.toutfaire.fr/adh_france/clavel$1 [P,L]
  RewriteRule ^corbier(.*)$ http://www.toutfaire.fr/adh_france/corbier$1 [P,L]
  RewriteRule ^db(.*)$ http://www.toutfaire.fr/adh_france/db$1 [P,L]
  RewriteRule ^duhornay(.*)$ http://www.toutfaire.fr/adh_france/duhornay$1 [P,L]
  RewriteRule ^eral(.*)$ http://www.toutfaire.fr/adh_france/eral$1 [P,L]
  RewriteRule ^estenaves(.*)$ http://www.toutfaire.fr/adh_france/estenaves$1 [P,L]
  RewriteRule ^euromat(.*)$ http://www.toutfaire.fr/adh_france/euromat$1 [P,L]
  RewriteRule ^fixeco(.*)$ http://www.toutfaire.fr/adh_france/fixeco$1 [P,L]
  RewriteRule ^freytet(.*)$ http://www.toutfaire.fr/adh_france/freytet$1 [P,L]
  RewriteRule ^gilles(.*)$ http://www.toutfaire.fr/adh_france/gilles$1 [P,L]
  RewriteRule ^guislain(.*)$ http://www.toutfaire.fr/adh_france/guislain$1 [P,L]
  RewriteRule ^jourlin(.*)$ http://www.toutfaire.fr/adh_france/jourlin$1 [P,L]
  RewriteRule ^julienne-dupont(.*)$ http://www.toutfaire.fr/adh_france/julienne-dupont$1 [P,L]
  RewriteRule ^lambert74(.*)$ http://www.toutfaire.fr/adh_france/lambert74$1 [P,L]
  RewriteRule ^lambert35(.*)$ http://www.toutfaire.fr/adh_france/lambert35$1 [P,L]
  RewriteRule ^lambert72(.*)$ http://www.toutfaire.fr/adh_france/lambert72$1 [P,L]
  RewriteRule ^lannoy(.*)$ http://www.toutfaire.fr/adh_france/lannoy$1 [P,L]
  RewriteRule ^lavergne-materiaux(.*)$ http://www.toutfaire.fr/adh_france/lavergne-materiaux$1 [P,L]
  RewriteRule ^lebreton(.*)$ http://www.toutfaire.fr/adh_france/lebreton$1 [P,L]
  RewriteRule ^limousin-materiaux(.*)$ http://www.toutfaire.fr/adh_france/limousin-materiaux$1 [P,L] 
  RewriteRule ^litzler(.*)$ http://www.toutfaire.fr/adh_france/litzler$1 [P,L]  
  RewriteRule ^martinazzo(.*)$ http://www.toutfaire.fr/adh_france/martinazzo$1 [P,L]
  RewriteRule ^mat-adour(.*)$ http://www.toutfaire.fr/adh_france/mat-adour$1 [P,L]
  RewriteRule ^mba(.*)$ http://www.toutfaire.fr/adh_france/mba$1 [P,L]
  RewriteRule ^meyer(.*)$ http://www.toutfaire.fr/adh_france/meyer$1 [P,L]
  RewriteRule ^michal(.*)$ http://www.toutfaire.fr/adh_france/michal$1 [P,L]
  RewriteRule ^groupe-michal(.*)$ http://www.toutfaire.fr/adh_france/groupe-michal$1 [P,L]
  RewriteRule ^montmirail(.*)$ http://www.toutfaire.fr/adh_france/montmirail$1 [P,L]
  RewriteRule ^moreau(.*)$ http://www.toutfaire.fr/adh_france/moreau$1 [P,L]
  RewriteRule ^moulet-materiaux(.*)$ http://www.toutfaire.fr/adh_france/moulet-materiaux$1 [P,L]
  RewriteRule ^moussy-construir(.*)$ http://www.toutfaire.fr/adh_france/moussy-construir$1 [P,L]
  RewriteRule ^nouvobois(.*)$ http://www.toutfaire.fr/adh_france/nouvobois$1 [P,L]
  RewriteRule ^pford(.*)$ http://www.toutfaire.fr/adh_france/pford$1 [P,L]
  RewriteRule ^pford.fr(.*)$ http://www.toutfaire.fr/adh_france/pford.fr$1 [P,L]
  RewriteRule ^picco(.*)$ http://www.toutfaire.fr/adh_france/picco$1 [P,L]
  RewriteRule ^pmd(.*)$ http://www.toutfaire.fr/adh_france/pmd$1 [P,L]
  RewriteRule ^revel(.*)$ http://www.toutfaire.fr/adh_france/revel$1 [P,L]
  RewriteRule ^sablemat(.*)$ http://www.toutfaire.fr/adh_france/sablemat$1 [P,L]
  RewriteRule ^sap(.*)$ http://www.toutfaire.fr/adh_france/sap$1 [P,L]
  RewriteRule ^schneider(.*)$ http://www.toutfaire.fr/adh_france/schneider$1 [P,L]
  RewriteRule ^semat(.*)$ http://www.toutfaire.fr/adh_france/semat$1 [P,L]
  RewriteRule ^serac(.*)$ http://www.toutfaire.fr/adh_france/serac$1 [P,L]
  RewriteRule ^simat(.*)$ http://www.toutfaire.fr/adh_france/simat$1 [P,L]
  RewriteRule ^solumat(.*)$ http://www.toutfaire.fr/adh_france/solumat$1 [P,L]
  RewriteRule ^somatrans(.*)$ http://www.toutfaire.fr/adh_france/somatrans$1 [P,L]
  RewriteRule ^steiner(.*)$ http://www.toutfaire.fr/adh_france/steiner$1 [P,L]
  RewriteRule ^sundgau(.*)$ http://www.toutfaire.fr/adh_france/sundgau$1 [P,L]
  RewriteRule ^tilhet(.*)$ http://www.toutfaire.fr/adh_france/tilhet$1 [P,L]
  RewriteRule ^tmc(.*)$ http://www.toutfaire.fr/adh_france/tmc$1 [P,L]
  # Minisites adherents belgique
  RewriteRule ^briqueterie-arlon(.*)$ http://www.toutfaire.fr/adh_belgique/briqueterie-arlon$1 [P,L]
  RewriteRule ^chantiersbeaumontois(.*)$ http://www.toutfaire.fr/adh_belgique/chantiersbeaumontois$1 [P,L]
  RewriteRule ^comptoirdemateriaux(.*)$ http://www.toutfaire.fr/adh_belgique/comptoirdemateriaux$1 [P,L]
  RewriteRule ^gilles(.*)$ http://www.toutfaire.fr/adh_belgique/gilles$1 [P,L]
  RewriteRule ^rochefort(.*)$ http://www.toutfaire.fr/adh_belgique/rochefort$1 [P,L]
  RewriteRule ^lacroix(.*)$ http://www.toutfaire.fr/adh_belgique/lacroix$1 [P,L]
  RewriteRule ^lengler(.*)$ http://www.toutfaire.fr/adh_belgique/lengler$1 [P,L]
  RewriteRule ^lizin(.*)$ http://www.toutfaire.fr/adh_belgique/lizin$1 [P,L]
  RewriteRule ^mbl(.*)$ http://www.toutfaire.fr/adh_belgique/mbl$1 [P,L]
  RewriteRule ^sonema(.*)$ http://www.toutfaire.fr/adh_belgique/sonema$1 [P,L]  
  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.90.2.5 2010/02/02 07:25:22 dries Exp $
Merci d'avance pour vos pistes, j'ai cherché du côté de RewriteCond %{HTTP_HOST} ^.fr ou de RewriteCond %{REQUEST_URI} !^/content.* mais sans succès (je ne maitrise pas du tout)

Cordialement
Ether.Kurios est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/02/2011, 22h22   #2
Rédacteur/Modérateur
 
Avatar de _Mac_
 
Inscription : août 2005
Messages : 8 278
Détails du profil
Informations forums :
Inscription : août 2005
Messages : 8 278
Points : 8 565
Points : 8 565
Pas compliqué, tu y étais presque : il faut mettre une condition RewriteCond qui vérifie le domaine avant la RewriteRule mais avec la bonne syntaxe (\.fr$ et pas ^.fr). On va donc se retrouver avec 2 règles pour cet adhérent :
Code :
1
2
3
4
RewriteCond %{HTTP_HOST} \.be$
RewriteRule ^gilles(.*)$ http://www.toutfaire.fr/adh_belgique/gilles$1 [P,L]
RewriteCond %{HTTP_HOST} \.fr$
RewriteRule ^gilles(.*)$ http://www.toutfaire.fr/adh_france/gilles$1 [P,L]
__________________

Du détail, du détail, du détail !!!
Revenons à la source : lisons la documentation et les fichiers de trace, la réponse à notre problème s'y trouve sans doute
_Mac_ est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 07/02/2011, 08h24   #3
Invité de passage
 
Kurios ETHER
Inscription : septembre 2010
Messages : 4
Détails du profil
Informations personnelles :
Nom : Kurios ETHER

Informations forums :
Inscription : septembre 2010
Messages : 4
Points : 3
Points : 3
Par défaut Souci résolu :-D

Bonjour,
Un grand merci pour ta solution qui fonctionne à merveille
Quel professionnalisme et quelle réactivité !

Encore merci !


Citation:
Envoyé par _Mac_ Voir le message
Pas compliqué, tu y étais presque : il faut mettre une condition RewriteCond qui vérifie le domaine avant la RewriteRule mais avec la bonne syntaxe (\.fr$ et pas ^.fr). On va donc se retrouver avec 2 règles pour cet adhérent :
Code :
1
2
3
4
RewriteCond %{HTTP_HOST} \.be$
RewriteRule ^gilles(.*)$ http://www.toutfaire.fr/adh_belgique/gilles$1 [P,L]
RewriteCond %{HTTP_HOST} \.fr$
RewriteRule ^gilles(.*)$ http://www.toutfaire.fr/adh_france/gilles$1 [P,L]
Ether.Kurios est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h24.


 
 
 
 
Partenaires

Hébergement Web