Discussion: mod_rewrite question
Afficher un message
Vieux 31/05/2007, 17h04   #2
Jim Hayter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_rewrite question

yawnmoth wrote:
> Say I have the following .htaccess file:
>
> RewriteEngine on
> RewriteRule (a|b|c)/(|index\.html) index2.html?type=$1
> RewriteRule (a|b|c)/(.*) $2?type=$1
>
> What I would expect this rule to rewrite http://www.domain.tld/a/ to
> http://www.domain.tld/index2.html and http://www.domain.tld/a/image.ext
> to http://www.domain.tld/image.ext.
>
> Unfortunately, that's not happening. What is happening is that
> everything in /a/ is being rewritten to index2.html - not just / and
> index.html, itself.
>
> My question is... what am I doing wrong and what I can I do to fix
> it?


Without an anchor, the first rule matches anything that has "a/"
anywhere in the URL. Try this:

RewriteRule (a|b|c)/(|index\.html)$ index2.html?type=$1

The $ specifies the end of the URL, so a/image.ext will not match the rule.

HTH,
Jim
  Réponse avec citation
 
Page generated in 0,06327 seconds with 9 queries