|
Home > Archive > Apache Server configuration support > June 2007 > mod_rewrite question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
mod_rewrite question
|
|
|
|
| Jim Hayter 2007-05-31, 1:24 pm |
| 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
| |
| yawnmoth 2007-06-11, 1:25 pm |
| On May 31, 10:04 am, Jim Hayter <see.reply...@nowhere.invalid> wrote:
> yawnmothwrote:
> <snip>
>
> 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
Thanks!
|
|
|
|
|