Yau Leung
Yau Leung

Reputation: 678

mod_rewrite of from example.com/ to example.com/home/ for certain user-agent

I know it should be simple. But always can't get it right. With the following, I can redirect example.com/abc into example.com/home/abc but not example.com/ to example.com/home

RewriteCond %{HTTP_USER_AGENT}  ^.*Chrome.*
RewriteRule ^([^/]+)/?$ home/$1

How can I redirect the / as well?

Upvotes: 1

Views: 157

Answers (1)

Jason McCreary
Jason McCreary

Reputation: 72971

If you want to redirect everything from Chrome to be under the home/ subdirectory, then try the following, it will match anything or nothing, and append it after home/

RewriteCond %{HTTP_USER_AGENT}  ^.*Chrome.*
RewriteRule ^(.*)$ home/$1

Upvotes: 1

Related Questions