RewriteCond seems not to work

New to mod_rewrite? This is a good place to start.

RewriteCond seems not to work

Postby michaelzach » Thu Sep 10, 2009 3:11 am

Hi all!

What I want to do is for an URL like http://www.example.com/person/123 to provide RDF whenever the Browser/Client has "rdf" within his accept header, and HTML otherwise.

But I always get HTML back, seems only the first rewritecond is matched.

How can that be?

TIA
Michael


RewriteCond %{HTTP_ACCEPT} !^.*rdf.* [nocase]

RewriteRule ^person/?$ http://www.example.com/index.php?id=47& ... ist_people [redirect=301,nocase,last]
RewriteRule ^person/(\d+).*$ http://www.example.com/index.php?id=47& ... how_person [redirect=301,nocase,last]

RewriteCond %{HTTP_ACCEPT} ^.*rdf.* [nocase]

RewriteRule ^person/?$ http://www.example.com/triplify/person [redirect=301,nocase,last]
RewriteRule ^person/(\d+).*$ http://www.example.com/triplify/person/$1 [redirect=301,nocase,last]
michaelzach
 
Posts: 1
Joined: Thu Sep 10, 2009 2:55 am

Postby richardk » Thu Sep 10, 2009 7:43 am

RewriteConds only apply to the next RewriteRule.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_ACCEPT} !rdf [NC]
RewriteRule ^person/?$ http://www.example.com/index.php?id=47&special=list_people [NC,R=301,L]
RewriteCond %{HTTP_ACCEPT} !rdf [NC]
RewriteRule ^person/(\d+)/?$ http://www.example.com/index.php?id=47&oid=$1&special=show_person [NC,R=301,L]

RewriteCond %{HTTP_ACCEPT} rdf [NC]
RewriteRule ^person(/\d+)/?$ http://www.example.com/triplify/person$1 [NC,R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 32 guests

cron