apache rewrite rule by HTTP_USER_AGENT

hi experts,

i have the attached rewrite rule. How to change the static /event/ param for each rule depending on the HTTP_USER_AGENT  to /mobileevent/ ?
I mean if somebody connects the page via a mobile device the ac param should be "event" and if somebody connects via Internet Explorer the ac param should be "mobileevent"

i´ve found something like:

RewriteCond %{HTTP_USER_AGENT} ^Mozilla.* [NC]
#RewriteCond %{HTTP_USER_AGENT} ^Lynx.*
#RewriteCond %{HTTP_USER_AGENT} ^MSIE*.*
#RewriteCond %{HTTP_USER_AGENT} ^Windows*.*
RewriteRule ^/$ http://www.domain.de/XY1/ [L]

RewriteCond %{HTTP_USER_AGENT} .*nokia.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*sharp.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*sonyericsson.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*mot-.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*samsung.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*sgh-.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*sagem.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*panasonic.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*symbian.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*symbian*.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*windows.ce*.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*pocket.pc.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*opera.mini.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*midp.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*vodafone.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*pda.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*mda.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*xda.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*sda.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*240x320.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*benq.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*portalmmm.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*blackberry.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*philips.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*safari.* [NC,OR]
RewriteRule ^/([^XY].*)$ /XY2/$1 [R]

in the internet. but how can i combine this code with my rewrite rules.



RewriteEngine On
Options +FollowSymlinks
RewriteBase /
 
ErrorDocument 404 /filenotfound.html
 
 
# Add trailing slash 
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
 
 
#rewrite country city plz kategorie umkreis edf edt p
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=events&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})&edt=(\d{1,2}\-\d{1,2}\-\d{4})&p=(\d{1,3})
RewriteRule ^test\.php$ /events/%1/%2-%3/%4/Umkreis_%5km/%6bis%7/seite%8/? [R=301] 
RewriteRule ^events/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})bis(\d{1,2}\-\d{1,2}\-\d{4})/seite(\d{1,3})/$ test.php?ac=events&country=$1&plz=$2&city=$3&se=$4&uk=$5&edf=$6&edt=$7&p=$8 [NC,L]
 
#rewrite country city plz kategorie umkreis edf edt
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=events&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})&edt=(\d{1,2}\-\d{1,2}\-\d{4})
RewriteRule ^test\.php$ /events/%1/%2-%3/%4/Umkreis_%5km/%6bis%7/? [R=301] 
RewriteRule ^events/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})bis(\d{1,2}\-\d{1,2}\-\d{4})/$ test.php?ac=events&country=$1&plz=$2&city=$3&se=$4&uk=$5&edf=$6&edt=$7 [NC,L]
 
#rewrite country city plz kategorie umkreis edf p
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=events&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})&p=(\d{1,3})
RewriteRule ^test\.php$ /events/%1/%2-%3/%4/Umkreis_%5km/%6/seite%7/? [R=301]
RewriteRule ^events/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})/seite(\d{1,3})/$ test.php?ac=events&country=$1&plz=$2&city=$3&se=$4&uk=$5&edf=$6&p=$7 [NC,L]
 
#rewrite country city plz kategorie umkreis edf
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=events&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})
RewriteRule ^test\.php$ /events/%1/%2-%3/%4/Umkreis_%5km/%6/? [R=301] 
RewriteRule ^events/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})/$ test.php?ac=events&country=$1&plz=$2&city=$3&se=$4&uk=$5&edf=$6 [NC,L]

Open in new window

bibabutzeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caterham_wwwCommented:
> I mean if somebody connects the page via a mobile device the ac param should be "event" and if somebody connects via Internet Explorer the ac param should be "mobileevent"

Not vis-a-vis, i.e. mobile device: mobileevent, dor the rest 'event'?
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
 
ErrorDocument 404 /filenotfound.html
 
 
# Add trailing slash (no cond needed in this case, processing is rule -> cond)
RewriteRule ^([^.]+[^/])$ http://%{HTTP_HOST}/$1/ [R=301,L]
 
# redirects /event/ --> /mobileevent/
RewriteCond %{HTTP_USER_AGENT} ^Mozilla [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Lynx [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^MSIE [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Windows
RewriteRule ^event/(.*)$ /mobileevent/$1 [R,L]
 
# redirects /mobileevent/ --> /event/
RewriteCond %{HTTP_USER_AGENT} nokia [NC,OR]
RewriteCond %{HTTP_USER_AGENT} sharp [NC,OR]
RewriteCond %{HTTP_USER_AGENT} sonyericsson [NC,OR]
RewriteCond %{HTTP_USER_AGENT} mot- [NC,OR]
RewriteCond %{HTTP_USER_AGENT} samsung [NC,OR]
RewriteCond %{HTTP_USER_AGENT} sgh- [NC,OR]
RewriteCond %{HTTP_USER_AGENT} sagem [NC,OR]
RewriteCond %{HTTP_USER_AGENT} panasonic [NC,OR]
RewriteCond %{HTTP_USER_AGENT} symbian [NC,OR]
RewriteCond %{HTTP_USER_AGENT} symbian [NC,OR]
RewriteCond %{HTTP_USER_AGENT} windows\.ce [NC,OR]
RewriteCond %{HTTP_USER_AGENT} pocket\.pc [NC,OR]
RewriteCond %{HTTP_USER_AGENT} opera\.mini [NC,OR]
RewriteCond %{HTTP_USER_AGENT} midp [NC,OR]
RewriteCond %{HTTP_USER_AGENT} vodafone [NC,OR]
RewriteCond %{HTTP_USER_AGENT} pda [NC,OR]
RewriteCond %{HTTP_USER_AGENT} mda [NC,OR]
RewriteCond %{HTTP_USER_AGENT} xda [NC,OR]
RewriteCond %{HTTP_USER_AGENT} sda [NC,OR]
RewriteCond %{HTTP_USER_AGENT} 240x320 [NC,OR]
RewriteCond %{HTTP_USER_AGENT} benq [NC,OR]
RewriteCond %{HTTP_USER_AGENT} portalmmm [NC,OR]
RewriteCond %{HTTP_USER_AGENT} blackberry [NC,OR]
RewriteCond %{HTTP_USER_AGENT} philips [NC,OR]
RewriteCond %{HTTP_USER_AGENT} safari
RewriteRule ^mobileevent/(.*)$ /event/$1 [R,L] 
 
#rewrite country city plz kategorie umkreis edf edt p
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=(events|mobileevent)&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})&edt=(\d{1,2}\-\d{1,2}\-\d{4})&p=(\d{1,3})
RewriteRule ^test\.php$ /%1/%2/%3-%4/%5/Umkreis_%6km/%7bis%8/seite%9/? [R=301] 
RewriteRule ^(events|mobileevent)/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})bis(\d{1,2}\-\d{1,2}\-\d{4})/seite(\d{1,3})/$ test.php?ac=$1&country=$2&plz=$3&city=$4&se=$5&uk=$6&edf=$7&edt=$8&p=$9 [NC,L]
 
#rewrite country city plz kategorie umkreis edf edt
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=(events|mobileevent)&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})&edt=(\d{1,2}\-\d{1,2}\-\d{4})
RewriteRule ^test\.php$ /%1/%2/%3-%4/%5/Umkreis_%6km/%7bis%8/? [R=301] 
RewriteRule ^(events|mobileevent)/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})bis(\d{1,2}\-\d{1,2}\-\d{4})/$ test.php?ac=$1&country=$2&plz=$3&city=$4&se=$5&uk=$6&edf=$7&edt=$8 [NC,L]
 
#rewrite country city plz kategorie umkreis edf p
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=(events|mobileevent)&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})&p=(\d{1,3})
RewriteRule ^test\.php$ /%1/%2/%3-%4/%5/Umkreis_%6km/%7/seite%8/? [R=301]
RewriteRule ^(events|mobileevent)/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})/seite(\d{1,3})/$ test.php?ac=$1&country=$2&plz=$3&city=$4&se=$5&uk=$6&edf=$7&p=$8 [NC,L]
 
#rewrite country city plz kategorie umkreis edf
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/test\.php\?ac=(events|mobileevent)&country=(\w{2})&plz=(\d{4,5})&city=([\w+\s\_\-]+)&se=(\w+)&uk=(\d{1,3})&edf=(\d{1,2}\-\d{1,2}\-\d{4})
RewriteRule ^test\.php$ /%1/%2/%3-%4/%5/Umkreis_%6km/%7/? [R=301] 
RewriteRule ^(events|mobileevent)/(\w{2})/(\d{4,5})-([\w+\s\_\-]+)/(\w+)/Umkreis_(\d{1,3})km/(\d{1,2}\-\d{1,2}\-\d{4})/$ test.php?ac=$1&country=$2&plz=$3&city=$4&se=$5&uk=$6&edf=$7 [NC,L]

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.