PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > Q about mod_rewrite flags
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

Q about mod_rewrite flags

Réponse
 
LinkBack Outils de la discussion
Vieux 19/01/2008, 10h20   #1
Jason Carlton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Q about mod_rewrite flags

I thought that I understood flags, but I guess not!

My site has a series of parked domains, and based on what domain is
typed in, the visitor sees different verbiage. However, a few bugs
have been that if they leave off the www or trailing slash, they're
redirected to the primary domain, seeing the wrong information.

To combat this, I'm using the following recipe in .htaccess:

RewriteEngine On
RewriteOptions MaxRedirects=2

RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [QSA]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

This works well, but not perfectly. It doesn't actually change the
address in the bar, so even though the page itself is found, images
and scripts that are loaded relatively don't load. I'm guessing that
the server still thinks that the page without the trailing slash is a
directory (it's just being tricked into showing a page), so the ../../
looks back one directory too far.

What flag would force the address to physically change? So if they
typed in http://mydomain.com/directory , the address bar would
automatically change to http://www.mydomain.com/directory/ ?

FYI, I read through the manual twice, but didn't see this answer. But
I'm sure that I've seen it discussed before on here, so I'm sure that
I'm just overlooking it.

TIA,

Jason
  Réponse avec citation
Vieux 21/01/2008, 14h44   #2
Trammel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Q about mod_rewrite flags

"Jason Carlton" <jwcarlton@gmail.com> wrote in message
news:1848bc26-7244-4378-acd9-f2b7b1596054@k2g2000hse.googlegroups.com...
>I thought that I understood flags, but I guess not!
>
> My site has a series of parked domains, and based on what domain is
> typed in, the visitor sees different verbiage. However, a few bugs
> have been that if they leave off the www or trailing slash, they're
> redirected to the primary domain, seeing the wrong information.
>
> To combat this, I'm using the following recipe in .htaccess:
>
> RewriteEngine On
> RewriteOptions MaxRedirects=2
>
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule ^(.+[^/])$ $1/ [QSA]
>
> RewriteCond %{HTTP_HOST} !^www\.
> RewriteRule (.*) http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]
>
> This works well, but not perfectly. It doesn't actually change the
> address in the bar, so even though the page itself is found, images
> and scripts that are loaded relatively don't load. I'm guessing that
> the server still thinks that the page without the trailing slash is a
> directory (it's just being tricked into showing a page), so the ../../
> looks back one directory too far.
>
> What flag would force the address to physically change? So if they
> typed in http://mydomain.com/directory , the address bar would
> automatically change to http://www.mydomain.com/directory/ ?
>
> FYI, I read through the manual twice, but didn't see this answer. But
> I'm sure that I've seen it discussed before on here, so I'm sure that
> I'm just overlooking it.
>
> TIA,
>
> Jason


Im new to mod_rewrite (I've only edited one from an example) but try here:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

This info contained in it looks like what your after:
'redirect|R [=code]' (force redirect)
Prefix Substitution with http://thishost[:thisport]/ (which makes the new
URL a URI) to force a external redirection. If no code is given, a HTTP
response of 302 (MOVED TEMPORARILY) will be returned. If you want to use
other response codes in the range 300-400, simply specify the appropriate
number or use one of the following symbolic names: temp (default),
permanent, seeother. Use this for rules to canonicalize the URL and return
it to the client - to translate ``/~'' into ``/u/'', or to always append a
slash to /u/user, etc.
Note: When you use this flag, make sure that the substitution field is a
valid URL! Otherwise, you will be redirecting to an invalid location.
Remember that this flag on its own will only prepend
http://thishost[:thisport]/ to the URL, and rewriting will continue.
Usually, you will want to stop rewriting at this point, and redirect
immediately. To stop rewriting, you should add the 'L' flag.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 17h19.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10567 seconds with 10 queries