Forum Moderators: phranque

Message Too Old, No Replies

Chain Flag?

wont work?

         

operafan

10:32 am on Nov 25, 2003 (gmt 0)

10+ Year Member



I've tried to use the C flag but it doesnt work
ex:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^opera [NC]
Rewriterule ^p\.html$ /p2.html [C]
Rewriterule ^t\.html$ /t2.html [L]

Becoz of the multiple rules that I have the second one t - t2 doesnt work.
I've tried without the C & put L as also it wont work the second rule?
Cant find real good examples with the C flag though.

Thanks - help appreciated.

jdMorgan

10:02 pm on Nov 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



operafan,

Rule two will only be applied after Rule number one matches and is applied. Since the URL cannot be both 'p.html' and 't.html' at the same time, I doubt that the Chain function is what you want.

How about:


RewriteCond %{HTTP_USER_AGENT} ^Opera [NC]
RewriteRule ^(p¦t)\.html$ /$1\2.html [L]

or, for a very long list of URLs:

RewriteCond %{HTTP_USER_AGENT} ^Opera [NC]
RewriteCond %{REQUEST_URI} ^/p\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/t\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/q\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/r\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/s\.html$
RewriteRule ^(.*)\.html$ /$1\2.html [L]

Functionally these are the same, but the second version would be easier to maintain with a long list of files.

Note that the backslash preceding the '2' in the rewriterule is probably not needed - I just put it in there to demarcate the $1 back-reference. Also, remember to replace the "¦" character with the solid vertical pipe character from your keyboard.

Jim
<edit> Corrected typos as pointed out in following posts </edit>

[edited by: jdMorgan at 6:08 pm (utc) on Nov. 26, 2003]

operafan

3:14 am on Nov 26, 2003 (gmt 0)

10+ Year Member



I'm having my fair share of errors/crashes :)
for the latter
cannot compile regular expression '^{.*}\.html$'
& first
cannot compile regular expression '^{p¦t}\.html$'

I'll fiddle around & see what seems to be the prob here.

jdMorgan

3:32 am on Nov 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



operfan,

The problem is that I typed it wrong -- Those should be () and not {}. I corrected it above, in case someone else cuts and pastes without reading further.

Jim

[edited by: jdMorgan at 3:39 am (utc) on Nov. 26, 2003]

operafan

3:38 am on Nov 26, 2003 (gmt 0)

10+ Year Member



Hahha, I'm still far off from reading :)
I've also noticed that you did not put % infront of the rewritecond & it still works.
Is it not necessary?
Tried it but doenst seem to work? It doesn't replaces it.

jdMorgan

6:09 pm on Nov 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, the "%" should be there - I corrected the code (again!)
Sometimes, I just can't type.

Jim